Last modified: 2011-05-02 20:08:36 UTC
Great work on the sortable tables javascript! When the javascript is applied to tables with a column that is a list of names (e.g. a table of US Senators with a column for the name, state, year elected, etc.) the script will sort by first name rather than last name, which is generally the wrong behavior. I would love to see a solution where a user could define a parameter for a particular column which would tell MediaWiki to sort that column lexicographically starting with the first letter of the last word in each cell (the last name). Perhaps this could be achieved by adding an html comment such as <!--LNAME--> to the first cell in the column. This is my first bug report so I apologize if its formatted incorrectly. :)
AFAIK, Brion is gonna remove sortable tables.
Currently the implementation of sortable tables is very unobtrusive HTML-wise (just a class), which makes it trivial to implement. Allowing some kinds of comments, which are currently stripped by the parser, is a nontrivial task, and possibly a dangerous one since IE can (by design!) be persuaded to execute arbitrary HTML inside them. Probably more sensible would be to uniquely ID all the rows and have some kind of one-line <script> tag for each that would give its sort key, but again, that would require Parser changes and could be dangerous. The only easy and non-dangerous thing I could think of would be to abuse the class attribute, but that's pretty hacky. Not as hacky as inexpertly matching a sort key to the background color and putting it at the beginning of the cell, though . . . (In reply to comment #1) > AFAIK, Brion is gonna remove sortable tables. I'm pretty sure he wasn't serious.
Incidently, GabrielF's suggestion to sort by the first letter of the last word in each cell (the last name) does not take into account two (or more) word names. For example, "John Van Dyke" would be sorted by "Dyke", while it should sort by "Van Dyke". Having the user explicitly give a sort key for each cell would work better.
Here are ideas how this could be accomplished: 1. One could add a column to the table with a class that inhibits its rendering, and needs a link to the column it is providing a sort key for. Imho that is too complcated because of the link, and will display the sort key column in CSS-unaware browsers, and requires editors to add another columns with proper CSS class for each cell. 2. Add an attibute to <td>s such as <td sortkey="van Dam, Joseph P. Anthony"> for cells needing one. It is ignored by html browsers, but the sorting (java)script could use them, and only resort to the cell content, if there is no sortkey attribute for a cell. This makes sorting slower, but since tables tend not to be excessively huge, that should be acceptable. 3. For sorting page titles, we could possibly utilize either of {{#DEFAULTSORT:page title}} or {{#DISPLAYTITLE:page title}} , provided, we add tables for them to the data base, and create these parser functions, which is pretty trivial with the appropriate data base fields.
Use data-sort-value="van Dam"