Sortable tables can be sorted on any column by clicking on the sort icon once for an ascending source, and clicking again for a descending sort.

Sometimes, for example with date ranges, we don't get the expected results. The fix for it is to use a sort key.

1. Here's the table as it was at 10:24, 10 September when Gimmetoo changed dashes to hyphens [1] – edit summary (-v):

Television
Year Title Role Episodes Notes
2004 Double the Fist Suzie 1 Episode name: "Fear Factory"
2005-
2006
headLand Freya Lewis 26
2007 Sea Patrol Fed Agent Martina Royce 1 Episode name: "Cometh the Hour"
2007-
Present
Chuck Special Agent Sarah Walker 54

Does an descending sort on 'Year' work properly?


2. Here's the table as it was at 10:14, 10 September when Rossrs restored the dashes [2] – edit summary (removed height. not sourced and not relevant. delinked common words per WP:OVERLINK, fixed dashes using a script):

Television
Year Title Role Episodes Notes
2004 Double the Fist Suzie 1 Episode name: "Fear Factory"
2005–
2006
headLand Freya Lewis 26
2007 Sea Patrol Fed Agent Martina Royce 1 Episode name: "Cometh the Hour"
2007–
Present
Chuck Special Agent Sarah Walker 54

Does an descending sort on 'Year' work properly?


3. Here's the table as it was at 02:33, 16 September when RexxS added a sort key [3] – edit summary (add hidden sort key to ensure accurate sorting):

Television
Year Title Role Episodes Notes
2004 Double the Fist Suzie 1 Episode name: "Fear Factory"
2005–
2006
headLand Freya Lewis 26
2007 Sea Patrol Fed Agent Martina Royce 1 Episode name: "Cometh the Hour"
9999 2007–
Present
Chuck Special Agent Sarah Walker 54

Does an descending sort on 'Year' work properly?


4. As long as we're doing it, for comparison here's another version that incorporates RexxS' other changes. The sort order of "2007" and "2007-present" is not the issue. Indeed, in this case, the 2007 appearance seems to have been in October 2007, while the 2007-present appearances started in September 2007, so that ordering is potentially ambiguous and would need some discussion to resolve.

Television
Year Title Role Episodes Notes
2004 Double the Fist Suzie 1 Episode name: "Fear Factory"
2005-
2006
headLand Freya Lewis 26
2007 Sea Patrol Fed Agent Martina Royce 1 Episode name: "Cometh the Hour"
9999 2007-
Present
Chuck Special Agent Sarah Walker 54

So here are the questions:

  1. Does changing dashes in date ranges to hyphen produce a table that sorts properly?
  2. Does adding a sort key (even with dashes in date ranges) produce a table that sorts properly?


5. Here is a version that should work in Safari 4 and use proper dashes.

Television
Year Title Role Episodes Notes
2004 2004 Double the Fist Suzie 1 Episode name: "Fear Factory"
2005 2005–
2006
headLand Freya Lewis 26
2007 2007 Sea Patrol Fed Agent Martina Royce 1 Episode name: "Cometh the Hour"
9999 2007–
Present
Chuck Special Agent Sarah Walker 54

By using a sort key on every cell in the column that contains mixed numbers and text, we can ensure an accurate sort on a wider range of browsers.