This piece of sample code allows users to sort data from a database
by simply clicking on the heading of the field they would like to
sort by. It's relatively simple to implement and can make finding
that certain database record much easier.
The code is pretty straightforward. Give it a look...
Alternate Version: Simpler Looking Header with Arrows
One of our readers recently sent me an email with some ideas to improve our database sort
sample above. Here's a excerpt from that email:
Rather than have two links, '+' and '-', you can remember the current state in a
variable and simply toggle between the two by clicking the field name itself. Or,
as I've done here, provide feedback as to the order by using arrows.
The code that was sent worked fine, but was a little complex and was obviously taken from
a highly modified version of the code. I've simplified things a bit and incorporated both suggestions:
the simpler UI (just clicking on the field name) and the indicator arrows.