Pinkie Pinkie - 3 years ago 130
Javascript Question

tinytable how to sort table in descending order rather then ascending

I'm using the tinytable table sorting script.

See example at

It's a very basic script about 2.5kb. To use the script we do

where table is the table id and 1 is the initial column to be sorted. This works great but initial column is sorted in asc order. There is not an option to make it initially sort in descending order. I tried to look into the js file but couldn't figure it out. What do I need to do to make it the initial column sort in desc order?

Answer Source

One line of the script reads return g>h?1:(g<h?-1:0).

Change it to return g<h?1:(g>h?-1:0) and you should be done.


If you click on the Name cell of the intial column, it also sort in descending order.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download