improved table sorting of decimal numbers
Closed, ResolvedPublic

Description

Author: eran_roz

Description:
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;"


Version: unspecified
Severity: normal

bzimport added a project: MediaWiki-Parser.Via ConduitNov 21 2014, 9:34 PM
bzimport set Reference to bz8115.
bzimport created this task.Via LegacyDec 1 2006, 3:06 PM
Phil_Boswell added a comment.Via ConduitDec 1 2006, 3:13 PM

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.

bzimport added a comment.Via ConduitDec 1 2006, 5:00 PM

robchur wrote:

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

bzimport added a comment.Via ConduitDec 4 2006, 2:44 AM

cohesion wrote:

This is a problem with any non-numeric character, including negative numbers
with "-". Some discussion here http://blog.webkist.com/archives/000043.html

bzimport added a comment.Via ConduitDec 5 2006, 9:30 PM

jackdt wrote:

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

bzimport added a comment.Via ConduitJan 19 2007, 4:11 PM

patrick.wikipedia wrote:

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.

bzimport added a comment.Via ConduitApr 14 2007, 11:06 PM

patrick.wikipedia wrote:

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

bzimport added a comment.Via ConduitApr 14 2007, 11:16 PM

patrick.wikipedia wrote:

Try again to make a link:

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

DieBuche added a comment.Via ConduitDec 20 2010, 12:13 AM

Fixed in upcoming jQuery version

DieBuche added a comment.Via ConduitJan 8 2011, 3:18 PM

fixed in patch for Bug 8028

DieBuche added a comment.Via ConduitApr 15 2011, 8:36 AM

r86088

brion added a comment.Via ConduitJun 22 2011, 8:02 PM

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

hashar added a comment.Via ConduitNov 10 2011, 3:31 PM

Assigning bug from DieBuche to me. Will check QUnit tests and write missing one.

hashar added a comment.Via ConduitDec 8 2011, 4:27 PM

Added some tests with r105560

Need to find out how to change the locale to redo the same tests with a different language.

RobLa-WMF added a comment.Via ConduitFeb 2 2012, 12:34 AM

This appears to be fixed. If there's a task associated with this that needs to be fixed, that should be a separate bug.

mxn added a subscriber: mxn.Via WebNov 24 2014, 8:53 PM

Add Comment