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

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T10115, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 8115 - improved table sorting of decimal numbers
improved table sorting of decimal numbers
Status: RESOLVED FIXED
Product: MediaWiki
Classification: Unclassified
Parser (Other open bugs)
unspecified
All All
: Normal normal with 5 votes (vote)
: ---
Assigned To: Antoine "hashar" Musso (WMF)
: need-unittest
Depends on:
Blocks:
  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: ---


Attachments

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;"
to
"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
point" 
> 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 http://blog.webkist.com/archives/000043.html
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
http://en.wikipedia.org/w/index.php?title=List_of_countries_by_murder_rate&oldid=92298115
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 
http://meta.wikimedia.org/wiki/Help_talk:Sorting for 
some more modifications, that allow numbers with commas 
or spaces as thousands separators, and in scientific 
notation.

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 
commas.

Also, please allow negative numbers.

See http://meta.wikimedia.org/w/index.php?
title=MediaWiki:Common.js&oldid=562970

Comment 7 patrick.wikipedia 2007-04-14 23:16:37 UTC
Try again to make a link:

 http://meta.wikimedia.org/w/index.php?title=MediaWiki:Common.js&oldid=562970
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
r86088
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.


Navigation
Links