Last modified: 2012-02-02 00:34:49 UTC

Wikimedia Bugzilla is closed!

Wikimedia has migrated from Bugzilla to Phabricator. Bug reports should be created and updated in Wikimedia Phabricator instead. Please create an account in Phabricator and add your Bugzilla email address to it.
Wikimedia Bugzilla is read-only. If you try to edit or create any bug report in Bugzilla you will be shown an intentional error message.
In order to access the Phabricator task corresponding to a Bugzilla report, just remove "static-" from its URL.
You could still run searches in Bugzilla or access your list of votes but bug reports will obviously not be up-to-date in Bugzilla.
Bug 8115 - improved table sorting of decimal numbers
improved table sorting of decimal numbers
Product: MediaWiki
Classification: Unclassified
Parser (Other open bugs)
All All
: Normal normal with 5 votes (vote)
: ---
Assigned To: Antoine "hashar" Musso (WMF)
: need-unittest
Depends on:
  Show dependency treegraph
Reported: 2006-12-01 15:06 UTC by Eran Roz
Modified: 2012-02-02 00:34 UTC (History)
4 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Description Eran Roz 2006-12-01 15:06:52 UTC
Recently a new option of sortable tables was added, but the sorting script
doesn't sort properly numbers with commas (like 12,000). an example:
{| class="sortable"
| numbers
| 12
| 8
| 9
| 8.000
and the results (from bigger to smaller number): "12", "9", "8", "8,000", and of
course it should be: "8,000", "12", "9", "8".

It should be noticed that the script works fine with dots (like 8.532). I'm
almost sure that the reason for this bug is wrong recognizing of numbers with
commas as strings, and not as numbers.
Maybe it can be fixed in sorttable.js by changing the line:
"if (itm.match(/^\s*[\d\.]+\s*$/)) sortfn = ts_sort_numeric;"
"if (itm.match(/^\s*[\d\.\,]+\s*$/)) sortfn = ts_sort_numeric;"
Comment 1 Phil Boswell 2006-12-01 15:13:48 UTC
Should this not also be subject to localisation? In some locales, the "decimal point" 
is represented by a period and the "thousand separator" by a comma; in others it is 
the other way around.
Comment 2 Rob Church 2006-12-01 17:00:01 UTC
(In reply to comment #1)
> Should this not also be subject to localisation? In some locales, the "decimal
> is represented by a period and the "thousand separator" by a comma; in others
it is 
> the other way around.

That's bug 8063. We could argue that this is a duplicate.

Comment 3 Judson (enwiki:cohesion) 2006-12-04 02:44:41 UTC
This is a problem with any non-numeric character, including negative numbers
with "-". Some discussion here
Comment 4 Jeandré 2006-12-05 21:30:50 UTC
"It should be noticed that the script works fine with dots (like 8.532)"

It doesn't always - see
and click 1995's sorting arrow once, scroll down,  and you'll see it's correctly
sorted. Click 1995's sorting arrow a second time and it now incorrectly sorts
the reals like strings: ... 7.12, 68.09, 6.85 ... instead of 68.09, 57.91 ...
7.12, 6.85 ...
Comment 5 patrick.wikipedia 2007-01-19 16:11:10 UTC
That has been fixed now, but see for 
some more modifications, that allow numbers with commas 
or spaces as thousands separators, and in scientific 

It also allows links in headers, by adding the HTML for 
the sort button to the existing HTML instead of to the 
inner text. That seems to work fine in the simple cases 
that I have tried.
Comment 6 patrick.wikipedia 2007-04-14 23:06:07 UTC
It is helpful that a comma in a number is now allowed 
as thousands separator, but please allow also multiple 

Also, please allow negative numbers.


Comment 7 patrick.wikipedia 2007-04-14 23:16:37 UTC
Try again to make a link:
Comment 8 DieBuche 2010-12-20 00:13:15 UTC
Fixed in upcoming jQuery version
Comment 9 DieBuche 2011-01-08 15:18:36 UTC
fixed in patch for Bug 8028
Comment 10 DieBuche 2011-04-15 08:36:15 UTC
Comment 11 Brion Vibber 2011-06-22 20:02:04 UTC
r86088 is seriously broken and may get reverted; reopening. Needs unit tests (see initial basic unit tests in r90595 which show up errors; will also need tests for the particular case this bug is about.)
Comment 12 Antoine "hashar" Musso (WMF) 2011-11-10 15:31:06 UTC
Assigning bug from DieBuche to me. Will check QUnit tests and write missing one.
Comment 13 Antoine "hashar" Musso (WMF) 2011-12-08 16:27:49 UTC
Added some tests with r105560

Need to find out how to change the locale to redo the same tests with a different language.
Comment 14 Rob Lanphier 2012-02-02 00:34:49 UTC
This appears to be fixed.  If there's a task associated with this that needs to be fixed, that should be a separate bug.

Note You need to log in before you can comment on or make changes to this bug.