User:Richardguk/Unstable tablesorter algorithm

Copy of issue raised at Village pump (technical)/Archive 98:

Unstable tablesorter algorithm
The current tablesorter algorith is "unstable": it does not preserve the relative order of rows where the cell content is equal.

For example, clicking the "Col 1" sort button twice in the table below should preserve the order of rows 2 to 8 (or invert them then restore them). But instead, the tie-break rows sort pseudorandomly (returning to the orginal order after 6 clicks instead of 2): It is confusing for tables to change the order of rows with identical sort values. Since Wikipedia articles are not expected to contain extremely large tables, computational optimisation should be less important than intuitive operation.

The current [//en.wikipedia.org/w/resources-1.19/resources/jquery/jquery.tablesorter.js jquery.tablesorter.js] JavaScript (trunk) claims to use a merge sort algorithm, but apparently not a stable one.

— Richardguk (talk) 03:53, 27 March 2012 (UTC)


 * Raised as 35526. — Richardguk (talk) 18:48, 27 March 2012 (UTC)


 * Previous VPT report archived as VPT/Archive 98. New report by User:Astronomyinertia at Village pump (technical)/Archive 101. Fix proposed by User:Anomie at 15638. — Richardguk (talk) 23:30, 13 July 2012 (UTC)


 * Included in proposed 1.20wmf9 update (scheduled to roll out to enwiki on 13 August 2012). — Richardguk (talk) 21:05, 2 August 2012 (UTC)


 * Fixed, despite initial glitch with 1.20wmf9 code (fixed in 39296).