User:RexxS/Sorting
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 [http://en.wikipedia.org/w/index.php?title=Yvonne_Strahovski&diff=383993673&oldid=383647703] – edit summary (-v):
class="wikitable sortable"
|+ Television |
Year
! Title ! Role ! Episodes ! Notes |
---|
2004
| Suzie | 1 | Episode name: "Fear Factory" |
2005- 2006 | headLand | Freya Lewis | 26 | |
2007
| Fed Agent Martina Royce | 1 | Episode name: "Cometh the Hour" |
2007- Present | Chuck | 54 | |
{{xt|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 [http://en.wikipedia.org/w/index.php?title=Yvonne_Strahovski&diff=384950004&oldid=384946857] – edit summary (removed height. not sourced and not relevant. delinked common words per WP:OVERLINK, fixed dashes using a script):
class="wikitable sortable"
|+ Television |
Year
! Title ! Role ! Episodes ! Notes |
---|
2004
| Suzie | 1 | Episode name: "Fear Factory" |
2005– 2006 | headLand | Freya Lewis | 26 | |
2007
| Fed Agent Martina Royce | 1 | Episode name: "Cometh the Hour" |
2007– Present | Chuck | 54 | |
{{xt|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 [http://en.wikipedia.org/w/index.php?title=Yvonne_Strahovski&diff=385089309&oldid=385017137] – edit summary (add hidden sort key to ensure accurate sorting):
class="wikitable sortable"
|+ Television |
Year
! Title ! Role ! Episodes ! Notes |
---|
2004
| Suzie | 1 | Episode name: "Fear Factory" |
2005– 2006 | headLand | Freya Lewis | 26 | |
2007
| Fed Agent Martina Royce | 1 | Episode name: "Cometh the Hour" |
Present | Chuck | 54 | | 2007–
{{xt|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.
class="wikitable sortable"
|+ Television |
Year
! Title ! Role ! Episodes ! Notes |
---|
2004
| Suzie | 1 | Episode name: "Fear Factory" |
2005- 2006 | headLand | Freya Lewis | 26 | |
2007
| Fed Agent Martina Royce | 1 | Episode name: "Cometh the Hour" |
Present | Chuck | 54 | | 2007-
So here are the questions:
- Does changing dashes in date ranges to hyphen produce a table that sorts properly?
- 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.
class="wikitable sortable"
|+ Television |
Year
! Title ! Role ! Episodes ! Notes |
---|
| Suzie | 1 | Episode name: "Fear Factory" | 2004
2006 | headLand | Freya Lewis | 26 | | 2005–
| Fed Agent Martina Royce | 1 | Episode name: "Cometh the Hour" | 2007
Present | Chuck | 54 | | 2007–
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.