What you want is to retrieve data from a database and then use the sorting. The easiest way is by using JavaScript.
You need front-end / client-side table sorter like
http://tablesorter.com/docs/#Demo
is it still possible to do with sort function?
It is possible in CakePHP, make array sort in afterFind method