Last modified: 2011-01-25 01:01:56 UTC
In file http://images.wikia.com/common/releases_200901.4/skins/monobook/allinone.js?5134 ts_resortTable does a trim: itm=itm.replace(/^[\s\xa0]+/,"").replace(/[\s\xa0]+$/,""); before using itm to work out which comparison function to use. However, it doesn't then trim the keyText when building the array to sort, and nor does ts_dateToSortKey. Consider the simple table {| class="wikitable sortable" ! Date || Event |- | 01 Apr 2000 || Something happened |- | 02 Apr 2000 || Something else happened |} This will result in table data cells with spaces: <table class="wikitable sortable"> <tr> <th> Date </th><th> Event </th></tr> <tr> <td> 01 Apr 2000 </td><td> Something happened </td></tr> <tr> <td> 02 Apr 2000 </td><td> Something else happened </td></tr></table> Because of the trim, ts_resortTable will detect that the first column contains a date, but when ts_datetoSortKey is passed ' 01 Apr 2000 ', of length 13 characters, it will fail to match any of the three known formats and so the sort key will be "00000000". As a result attempting to sort by the first column won't change the order at all (stable sort and every row generates the same sort key). The result is that sorting is very fragile. The simple fix is to append after the line var keyText=ts_getInnerText(row.cells[column]); a further line keyText=keyText.replace(/^[\s\xa0]+/,"").replace(/[\s\xa0]+$/,"");
Was just about to open this same issue when I came across this. BTW my fix was to add this as the first line of ts_dateToSortKey: date = date.replace(/^\s+|\s+$/g,""); // trim white space Oh, just noticed that this is reported against a different file. My issue was in skins/common/wikibits.js.
Confirmed with $wgUseTidy off. Peeking...
Done in r53495 -- added the trim on the sort key preprocessor call as well as the selection.