Sorting a Table with the Javascript Prototype Library

Number String Date
2 Sometimes 08/30/1999
0 I 12/21/2022
1 Eat 01/01/1111
01 Many 11/05/1755
22 Plump 06/16/1981
-3 Pigs. 03/22/2006

The example uses Javascript to sort the rows of the table. Click the column headers to see the sorting in action. The Javascript I've written uses the Prototype Javascript library (1.5.0_pre1) that introduced the ability to use CSS selectors to target DOM elements.

I'm also using the Enumerable.sortBy() method to perform the logic of sorting the rows. sortBy() is easy to use because you only need to feed it the string or number you want compared, and it'll do the rest. Take a look at the Javascript.

Notes