Skip to content

Sort Tabular Data

I hate the way that tabular sorting is typically done in web apps (make links on every column with sort_order="columnname" or similar). It is tedious to code, and requires a lot of bandwidth and round trips from the server, not to mention additional load on the database.

Well, today I Googled a bit, and found SortTable.js. Add the script, and add a "sortable" class to the table you wish to sort, and you're done. It automatically detects string, numeric and date columns and sorts them using a very quick (though non-stable) sort.

I only had a very small problem (some of the CSS styles in FF3 stopped working) with the mechanism used to set the table up to be sortable (window.onload replacement), so I switched it to use jquery(document).ready, which happens later in the page loading process. Works nicely.

Check out the documentation for additional features.

Trackbacks

No Trackbacks

Comments

Display comments as Linear | Threaded

No comments

Add Comment

Enclosing asterisks marks text as bold (*word*), underscore are made via _word_.
Standard emoticons like :-) and ;-) are converted to images.
E-Mail addresses will not be displayed and will only be used for E-Mail notifications.

To prevent automated Bots from commentspamming, please enter the string you see in the image below in the appropriate input box. Your comment will only be submitted if the strings match. Please ensure that your browser supports and accepts cookies, or your comment cannot be verified correctly.
CAPTCHA

Form options