Help talk:Sorting

From Meta, a Wikimedia project coordination wiki
Jump to: navigation, search


Reverse order sort[edit]

How do I reverse order sort based on the order of the items in the list? I want to reverse the order of the items irrespective of date, currency, numeric, or string, but only by how the items first appear on the list. XP1 18:25, 12 April 2009 (UTC)

Alphanumeric Sorting[edit]

Alphanumeric sorting doesn't seem to be supported by mediawiki tables. Look at the example below. If you try to
to sort by the Title, you will get a wrong result. Is there any easy solution for this?

Title State Number
Document 1 Finished 1
Document 2 Not Finished 2
Document 3 Not Defined 3
Document 4 Not Defined 4
Document 5 Not Defined 5
Document 6 Not Defined 6
Document 7 Not Defined 7
Document 8 Not Defined 8
Document 9 Finished 9
Document 10 Finished 10
Document 11 Finished 11

sort numerical[edit]

in the test for a numerical sort the plus (+) and minus (-) sign should be added to the match. So replace

if (itm.match(/^[\d.,]+\%?$/)) {
  sortfn = ts_sort_numeric;

by

if (itm.match(/^[\d.,\-\+]+\%?$/)) {
  sortfn = ts_sort_numeric;

and sorting of numbers works nice for numbers with sign (+1, -1, ...)

--87.163.193.10 17:44, 29 July 2007 (UTC)


Describe standard[edit]

Please restore help for standard sortable version that's used in most projects. This help page is not about meta.wikimedia.org, it's supposed to help readers with all Wikimedia projects. Modified version should be described on a separate page ∴ Alex Smotrov 13:44, 13 August 2007 (UTC)

For now I added a link to an old version of the page, from before modifications of the JavaScript were specified in MediaWiki:Common.js. However, note that for the examples to work according to the description of any version, the page describing that version should be viewed at a wiki where it applies.--Patrick (talk) 11:49, 16 August 2007 (UTC)
(In response to your answer on the talk page): at least you could explain all the differences and also list some projects currently using new code.
Do you mind if I restore (and then improve) the description of "standard" version and then move your description to, say, Help:Sorting (modified)? ∴ Alex Smotrov 14:33, 16 August 2007 (UTC)
I have now removed the modifications of the JavaScript specified in MediaWiki:Common.js, so that Meta works in the standard way, which was recently improved. I have adapted the page Help:Sorting.--Patrick (talk) 09:07, 15 September 2008 (UTC)

Table with colspanned cells[edit]

Try to edit the tables in List of Colorado Avalanche players making'em sortable and show the preview. Then try to sort by name and you'll see... --82.58.27.164 13:57, 18 August 2007 (UTC)

Please provide info and/or ask a question. Perhaps you are saying that you confirm Help:Sorting#Limitations?--Patrick (talk) 00:08, 19 August 2007 (UTC)
Yes, and I think it must be fixed as soon as you can. --82.58.27.164 09:29, 19 August 2007 (UTC)

Predefined sorting[edit]

How I can make a predefined sorting? I.e., pt:Karlspreis — how I can set this table to sort by name, instead by year? Note that I mean to sort at the time of article's page is open. Slade 03:25, 16 September 2007 (UTC)

That is not possible, you have to sort the wikitext.--Patrick (talk) 11:15, 16 September 2007 (UTC)

How to specify sorting mode?[edit]

The page does not make clear how to specify the sorting mode. I had a column with entries such as "123 matches" but it was being alpha sorted. Following "the element ends with "sm=n" (without the quotes; it stands for "sort mode = numeric")", I tried sm=n in the column header's options and in the column header text without any success. However one specifies the sort mode should be clarified. (SEWilco 16:23, 20 September 2007 (UTC))

That's the biggest problem with this Help page: it's not helping users from other projects. The en.wp JavaScript version doesn't know anything about sm=n. See #Describe standard section above. I was going to rewrite the page to the standard (not Meta) version, but unfortunately I don't have the time right now. Oh, and the answer to your question: make sure all column entires start with a number or use hidden spans that start with a number ∴ Alex Smotrov 18:08, 20 September 2007 (UTC)

Isolating Columns[edit]

Is there anyway to isolate a column from the sorting function? I'm mainly interested in keeping a list of numbers (1-200) static at the side of the column while sorting various values. The numbers are there so you can compare the rank of different subjects. I know how to keep the numbers from being sortable, but I want the column to remain in order (1-200) while the other columns can be rearranged. Farside268 15:18, 8 October 2007 (UTC)

I don't think this is possible. Perhaps with two side-by-side tables, keeping the height of corresponding rows the same.--Patrick (talk) 21:30, 8 October 2007 (UTC)
I added the section Help:Sorting#Static_column on this.--Patrick (talk) 13:57, 1 November 2007 (UTC)

[cricobr] I have just finished fixing the sorting of the table at en:Abundances_of_the_elements_(data_page)#Sun_and_solar_system. As soon as this was done I realised that it would be neat to have a rank column at the left of the table, the contents of which remained static regardless of which column was sorted. It soon became apparent that this was not possible. That was what brought me here. Clearly there is a need for this. The example referenced from the help page, en:Ranked list of Dutch provinces, reinforces the need. If the first table on that page had a rank column there would be no need for the following two tables. The maintenance of the page would also be simpler, and it would be possible to establish rank for ANY column in the first table, not just for the columns chosen by the editors.

There must be hundreds, if not thousands, of Wikipedia tables where a rank column would be useful. Above, Patrick says he thinks it is not possible. But, surely it must be POSSIBLE to implement this feature in some way, even if it is not possible with the current sorting code. I have no idea where the code is, or what it looks like, but as a programmer (of sorts!) I can see no reason why the sort code cannot respond to some sort of 'tag' in the header cell of a column, such as 'class="ignore" |' which simply tells the code to literally 'ignore' the tagged column, and always maintain the cells of that column on the same row. As this would be an additive change it would cause no problems of compatibility with old tables, as it would simply be a new feature, to be implemented if and when it appears.

Just adding my voice to the need already expressed above. (Though I wonder if anyone will read this, as it seems the above discussion took place in 2007! I wonder if there is any way to bump a thread up the discussion thread list as happens automatically with email?)

Cricobr 15:32, 8 June 2011 (UTC)

Headers[edit]

Is there a way to either isolate header rows within a long table to keep them from being sorted or to create a floating header row that will stay with the table as you page down? I'm trying to sort a long table – about 200 items – and it would be helpful if I could keep headers every 20-30 lines for ease of reference. Farside268 15:18, 8 October 2007 (UTC)

I've been wondering this myself. I have a table with many many rows, and I have put header rows every 10 or so entries so that readers can keep track of what all the columns mean, but when they sort the table, all the header rows get sorted. What I've done so far is just to make them sort to the bottom to get them out of the way, but it doesn't really solve the problem. -128.2.247.44 15:14, 2 February 2009 (UTC)

Infinity?[edit]

Hi folks, does anyone know whether it's possible to sort tables by columns that contain either "regular" floating point numbers or (positive) infinity? I need to work with data like that, and currently, columns that contain infinite values are treated and sorted as strings, not numbers, but that's not really helpful, of course. (BTW, right now, I'm representing infinity as "+∞", but I could certainly change that to something else like "Inf" or "+Inf" or so, too.) -- Schnee 19:37, 13 October 2007 (UTC)

Firefox problem with sorting on a column of numbers[edit]

The table in this article, when sorted on the third column, which is numerical, doesn't produce the expected (correct) result. The cause isn't obvious to me, even after reading this page, the archive of this page, and the help page itself. Could someone point out the problem?

Addendum: apparently the problem is with Firefox 2. By contrast, Opera 9 and IE7 work perfectly fine for me. Is this a known bug, or do I have some sort of setting wrong? John Broughton 15:23, 12 November 2007 (UTC)

Okay, nevermind. I fixed one number that had problems (it had commas) and the problem seems to have gone away. John Broughton 15:25, 12 November 2007 (UTC)

Default Sort?[edit]

Is it possible to cause a table to display sorted? That is, I want a table of numeric values to appear sorted when the page is loaded without having to re-order all of the table elements. Is this possible? Claytonius3 21:16, 27 November 2007 (UTC)

No, see Help:Sorting#Sorting_the_wikitext_of_a_table.--Patrick (talk) 01:21, 28 November 2007 (UTC)

Sort Direction[edit]

Is it possible to choose a default sort direction for a column? By default, a column of numbers will always be sorted from lowest to highest. If I want to sort from highest to lowest, I need to click it again. Okay, no big deal, one extra click, but say I've got a whole bunch of columns that I'd like to swap between - those extra clicks add up. The only way I can think of to make a column sort in reverse by default is to use a hidden sort key, e.g.:

Normal Sort Reverse Sort Fruit
1 91 Banana
2 55 Apple
3 28 Dill Pickle
4 64 Cucumber
5 37 Eggplant

Which, yes, it works, but gads, that's tedious. (Especially since the table I want to do this on is considerably larger than this example.) Even after I made a {{hide}} template to do all that span-stuff, it's still a pain. Is there some way to just tell that column to do a high-low sort first by default? 70.119.42.36 22:22, 11 December 2007 (UTC)

Yes, I would very much like this feature. It would be very useful for this Wikipedia page [1] about GDP. When a user wants to sort by GDP, he almost certainly will want to sort it by reverse. Kent Wang 08:36, 17 November 2008 (UTC)

Can't get a table to sort![edit]

I am trying to change w:List of Nintendo DS games to a sortable list. I have the work I have done so far saved here: w:User:Bse3/Sandbox. For some reason I cannot get the far right column to sort. All the other columns work just fine. I broke up the table into many sections to see where the problem is. I changed one part that was missing a line to make that section work, but when I put it all together it still will not work. Since there are many lines I could have easily overlooked something but I'm pretty sure I checked it all. I know that sort keys still need to be added for that far right column but that's another job. For now I just want the thing to do something in the first place! Hopefully someone knows what to do. Thanks. —137.186.165.215 06:09, 11 January 2008 (UTC).

Never mind. I fixed it; same problem, just missed another line. –137.186.165.215 04:25, 13 January 2008 (UTC)

Sorting problems with a table that has colspans[edit]

The table in article [2] does not sort right. It can only sorted by the first column (instead of by all colums - does this have to do with the use of colspans?), and the probably the sortbottom syntax is not used correctly. Would be nice if someone could look at it.--Ratzer 15:52, 18 January 2008 (UTC)

I took the colspans out, and changed decimal commas into points, it seems to work now.--Patrick (talk) 00:06, 19 January 2008 (UTC)
If sorting doesn't work in tables that have colspan entries (although at the end, marked as not sortable), is this a feature or a bug? :-) If it is a bug, I would like to ask the programmers to fix it.--Ratzer 09:53, 14 March 2008 (UTC)

very tricky sorting problem[edit]

Hi everybody, I would like to make this Corruption_perceptions_index sortable. I know there is a general way to make columns sortable. However, how do you make only certain columns sortable, when there is more then one row at the top? (only the columns "Rank", "Country" and the years "2007", "2006", etc. should be sortable.) While this is probably easy to solve (I hope), there is an additional twist to it. The table is split in two parts! Is it possible to have the sortable buttons only on the left side, but still make it function for the entire table? Thanx for helping out! --Spitzl 19:54, 29 January 2008 (UTC)

Making a column unsortable example not working[edit]

The Help:Sorting#Making a column unsortable example does not seem to work for me, i.e. all of the columns sort on the example. --LRG 00:46, 30 January 2008 (UTC)

Nevermind, I get it. The column still sorts, but you can not sort on the column. --LRG 00:48, 30 January 2008 (UTC)


How to Sort Dates?[edit]

When I attempt to sort the data (dates) in Table A, it gets sorted in alphabetical order ... and not in chronological date order. Is there any way to make Table A sort in correct chronological date order? Please don't tell me that I have to resort to something that looks like Table B ... or do I? Table B does indeed sort in correct chronological date order, but clearly those are unconventional (and virtually unrecognizable) date formats. Are there any alternatives at all to make this work correctly? Thanks. (Joseph A. Spadaro (talk) 07:06, 7 February 2008 (UTC))

Table A
Date of Birth
May 3, 1930
May 1, 1930
May 12, 1930
May 22, 1930
April 11, 1900
April 3, 1900
September 5, 1700
August 5, 2008
February 1, 1894
July 1, 1902
Table B
Date of Birth
1930-05-03
1930-05-01
1930-05-12
1930-05-22
1900-04-11
1900-04-03
1700-09-05
2008-08-05
1894-02-01
1902-07-01
Solution: use a hidden sortkey (explained on the help page). P.S. I believe this is yet another indication that this help page could be improved .. a lot ∴ AlexSm 14:53, 7 February 2008 (UTC)
Thanks for your reply. I do not know much about tables, charts, etc. --- other than the most very basic functions. So, to be honest, I did not understand your reply at all. Can you please clarify it for me? Thanks. Specifically ... what is a hidden sortkey and how do I employ it? ... and ... where is that help page that you are referring to? Thanks a lot. (76.239.45.253 15:04, 7 February 2008 (UTC))
Help:Sorting, this is the discussion page of that page.--Patrick (talk) 15:30, 7 February 2008 (UTC)
OK. Thanks a million. I figured it all out, with your Help. Thanks! (76.233.5.39 04:27, 8 February 2008 (UTC))
those are unconventional (and virtually unrecognizable) date formats
I disagree, en:ISO 8601 date is so much nicer to read. You don't have to jump back and forth on the line to see the most significant part (the year), the dates are all a consistent width, you don't have a comma illogically breaking up a single conceptual unit. ISO8601 is better, evolve and enjoy. -- skierpage 21:11, 1 June 2010 (UTC)

Portuguese language sorting problem[edit]

Is there anyway to sort a string column with non-english letter? For example, Á, É, Õ, etc? thanks, Charley Vasconcelos 11:39, 7 February 2008 (UTC)

Special Javascript code for this would be useful. Otherwise, use a hidden sortkey, e.g. AÁ for Á, this would position it between AZ and BA, or A, to put Áq between Ap and Ar.--Patrick (talk) 15:44, 7 February 2008 (UTC)
Thanks a lot, Patrick. Charley Vasconcelos 10:07, 8 February 2008 (UTC)

Reset Tables Original Order[edit]

How can one reset the tables original order? I've tried creating another column with the original order as numbers, but the problem is that when adding and removing items the order numbers must be updated, not a difficult task, but a tedious one when you've dealing with large lists of items. Is there either a mechanism whereby the original order can just be restored, or perhaps some sort of tag/template/extension that can create lists of numbers across table rows so that the numbers are present in HTML but need not be explicitly defined in wikitext.

Thanks. --Wahooney 13:11, 11 April 2008 (UTC)

The tables are reset by refreshing the page, depending on the browser this is e.g.done with Ctrl-F5. Apart from that, if the original order is meaningful it can probably also be obtained by sorting a column, or by adding a column with the data on which the order is based.--Patrick (talk) 00:42, 12 April 2008 (UTC)

Total row for selected columns only[edit]

Name Surname Height
John Smith 1.85
Ron Ray 1.89
Mario Bianchi 1.72
Average: 1.82

Using the example on the main page, this table had a total row. Having removed the sortbottom class, the total row is now sorted. Whilst this is silly for the Name and Surname column, it is useful for the height column. You can immediately see Mario Bianchi is below average height.

Is it possible to choose which columns the sortbottom class applies to, or is there another way to display where an average lies? ++ MortimerCat 12:00, 5 May 2008 (UTC)

Re-write with a better section layout[edit]

Please, if somebody plans to re-write this help, please do it. The issue is to separate a section for meta-specific functionality from the main body of text. The main body should provide solutions that will work almost everywhere (especially on English Wikipedia!). I'm probably yet another user that just wasted a lot of time, because sm=n just does not work. --Kubanczyk 10:35, 10 June 2008 (UTC)

Time[edit]

How can I make time, such as 12 pm, go before 10 pm and 11 pm in a sortable table? Odessaukrain 20:03, 20 July 2008 (UTC)

See Help:Sorting#Alphabetic_sorting_with_hidden_sortkey.--Patrick (talk) 09:24, 21 July 2008 (UTC)

Templates[edit]

Hello, I have a problem with sorting data from teplates in a sortable table.

Here I've used a table "wikitable sortable" to sort numeric data of two types: numbers in templates and numers without templates. The numbers in templates do not sort in the proper way. 11.434,22 precedes 377.914,78.

Please, explain me how to make these numbers in the template to sort correctly. Thank you. --Alex K 14:10, 26 August 2008 (UTC)

Do not use text in the number column.--Patrick (talk) 09:45, 15 September 2008 (UTC)

sm=n ?[edit]

This article keeps referring to the possibility of putting "sm=n" in cell to ensure numeric sorting, but I can't find any reference to this in the javascript code. Has it been deleted from the software but just not from the article? Blue-Haired Lawyer 15:42, 14 September 2008 (UTC)

I recently removed from MediaWiki:Common.js the possibility of putting "sm=n", and have now adapted the help page.--Patrick (talk) 09:12, 15 September 2008 (UTC)

Ignoring extra info[edit]

It would be extremely helpful if it were possible to put a tag on certain fields which displays text, but is ignored by the sorting algorithm. See the example on this page. The years in the "Admission to Union" column sort normally for the most part, but those few with superscripts indicating notes on the bottom all end up improperly ordered. The only method I know to make that column sort properly (other than separating the notes into a new column, which is ugly) would require adding a hidden sortkey to every single cell in that column. As it is, I already had to do that to the Area column in order to make that sort properly, but the code is bulky, and way more complicated that it by all rights should be. If it were possible, just on certain exceptional cases, to add a tag saying "Display this, but ignore it when sorting", it would be a much more graceful solution to the problem. (This could also be added to templates such as the "km2 to sq mi" template currently being used in the Area column - this would make the sortkey unnecessary, as the template could display one value, but only use the output number for sorting. Just a suggestion in case any of the developpers of this feature want to consider adding the feature. Lurlock 21:13, 5 October 2008 (UTC)

problem with 2 row - header - table[edit]

look at that excample: en:Comparison_of_e-mail_clients#Protocol_support There are two header-rows and whcih shouldn't be sorted. how can I do this? there are many different software comparison there these tips is useful! thanks Mabdul 18:23, 10 October 2008 (UTC)

AFAIK, you can't. Also rowspans and colspans generally don't play nicely with sortable tables. What I'd do is separate the header into two rows (removing all row/colspans) and then make the first row actually a separate table, using fixed column widths to get them to line up. A bit clunky, but the only way I know to do this sort of thing. Alternatively, you could redesign the table such that the header row is color-coded to indicate grouping, rather than having the extra header row to group the secondary row together. Lurlock 19:35, 13 October 2008 (UTC)
I went ahead and fixed the chart for you. It added a little bit of redundancy to the headers, but this was necessary in order to eliminate the row/colspans and make the chart actually sort properly. Lurlock 13:00, 17 October 2008 (UTC)

Help request[edit]

Hi guys, could you help me with a table I'm authoring here, I can't get it to sort properly.

I'm taking the data from a table in the link at the top of the article. I can't get the red "X boxes" to sort, the table's not "filled in" yet, is that the problem. 86.8.31.145 10:15, 19 December 2008 (UTC)

The sort mode is determined by the table element that is at the time of sorting in the first non-blank row below the header, so with data not filled in the sort mode can be different from what is desired.--Patrick (talk) 22:42, 12 April 2009 (UTC)

Help please[edit]

Hi, I have a sortable table at Wikipedia:list of coal mines in the United States that will sort on the first and last columns, but doesn't seem to want to sort on the middle columns. Any help would be appreciated. Thanks. Bantman 16:35, 22 April 2009 (UTC)

I fixed it by removing the empty row (with the wrong number of cells) at the bottom.--Patrick (talk) 22:15, 22 April 2009 (UTC)

Can the sorting icon be put below the column text?[edit]

In tables with many year columns it would lessen the table width if the clickable sorting arrow was below the year in the column titles.

See: en:List of countries by intentional homicide rate#2000s

I see the problem in the Opera browser and in Internet Explorer. I don't see the problem in the Firefox browser. --Timeshifter 09:31, 4 May 2009 (UTC)

Synch this copy with the one on en?[edit]

en:Help:Sorting is quite a bit out of date... for example, it still talks about the "sm=n" junk, which is pretty confusing. Should it be updated with meta's version? --Fjarlq 09:48, 9 May 2009 (UTC)

The English Wikipedia has abandoned the policy of using exactly the same wikitext, and using templates to allow for differences (see e.g. [3]), so merging by hand would be needed.--Patrick (talk) 21:09, 10 May 2009 (UTC)
OK, I merged it by hand. --Fjarlq 10:51, 13 May 2009 (UTC)

Proposed enhancements to table sorting[edit]

See en:Wikipedia:Village pump (proposals)#Proposed enhancements to table sorting (rowspan/colspan support). -- Tcncv 02:51, 27 May 2009 (UTC)

Sortable, but only 2nd row[edit]

Parliament
Lower assembly Upper assembly
Party Seats Party Seats
Blue 24 Green 4
Red 21 Black 3

Hi there, maybe a stupid question, but I'll ask it anyway: I wanted to create a wikitable sortable, but only for the second row (so first row just being unsortable) ... I tried several things, but nothing seems to work ... Just for an example: how can I make the row "Party" and "Seats" sortable for each column?

Thanks alot in advance, --Ianus (de)

Workarounds:
Parliament
Assembly Party Seats
Lower LBlue L24
Lower LRed L21
Upper UGreen U04
Upper UBlack U03
Parliament
Lower assembly Upper assembly
Party Seats Party Seats
B Blue 24 G Green 4
R Red 21 B Black 3

Sortable, dates: dmy or mdy confusion[edit]

Date format seems to be assumed as mdy rather than dmy

see Help:Sorting#Dates. This seems to say that dmy is expected

--Richardgmcmahon 10:28, 2 December 2009 (UTC)


Date sort mode Date
01-12-2007 01 Dec 2007
20-11-2007 20 Nov 2007
02-10-2007 02 Oct 2007
02-09-2007 02 Sep 2007
04-08-2007 04 Aug 2007

Older versions[edit]

217.132.219.162 20:22, 2 January 2010 (UTC) Is there a way to add this feature to older versions? I'm using Mediawiki 1.6.10 on Php 4, Mysql 4, and due to technical problems with my hosting service provider, upgrading to a newer version is problematic. Is there some hack/patch? I saw the DataTable extension, but obviously I don't want to use anything that is labeled as a major security risk.

Any help would be appreciated The preceding unsigned comment was added by 217.132.219.162 (talk • contribs) 20:22, 2 January 2010 (UTC)

You could try copying the newer sorting code from wikibits.js to your Common.js. -AlexSm 15:34, 26 August 2010 (UTC)

Non-breaking spaces[edit]

(link to current version)

The section "Unsuitability of padding with no-break spaces" (probably added in 2007) might be outdated now. Right now ts_resortTable() in wikibits.js has the line replace(/^[\s\xa0]+/, "").replace(/[\s\xa0]+$/, "") to remove all spaces from the start and the end of the cell value. Since for normal browsers (Firefox) the expression /\s/.test('\xa0') yeilds true, the \xa0 part must have been added specifically for IE. -AlexSm 15:34, 26 August 2010 (UTC)

This seems to make the section "Server issue" below obsolete as well, since it looks like the unbreakable space (look for "french spaces" in Parser.php) can only be added to the end of the cell in the expression like ! cell1 !!cell2. -AlexSm 15:34, 26 August 2010 (UTC)

If there are no objections, I will remove or rephrase these sections. -AlexSm 18:13, 30 August 2010 (UTC)

IP addresses[edit]

I'm looking for a solution to sort the IP addresses. I think because of the point the parser is lost. Has anyone an idea?

IP Description
192.168.200.03 IP address 03
192.168.200.10 IP address 10
192.168.200.01 IP address 01

with an underline in the front then it works, is there a better way to do that?

IP Description
_192.168.200.03 IP address 03
_192.168.200.10 IP address 10
_192.168.200.01 IP address 01

--Lionelr 14:07, 25 February 2011 (UTC)

well a tip is to put a character on the end and to hide it like this
IP Description
192.168.200.03_ IP address 03
192.168.200.10_ IP address 10
192.168.200.01_ IP address 01

--Lionelr 14:18, 25 February 2011 (UTC)

This is what Lionel used, and worked for me:

<font color="#f9f9f9">_</font>
  • -added for simplicity's sake. --Teststudent 22:33, 21 November 2011 (UTC)


mmhhhh in fact it is not so easy to sort IP addresses!! --Lionelr 14:54, 25 February 2011 (UTC)
well I think i got it, I use a template for the IP called {{{IP}}} where the 4 classes are the parameters <span style="display:none">{{#expr:{{{1}}}e9+{{{2}}}e6+{{{3}}}e3+{{{4}}}}}</span>{{{1}}}.{{{2}}}.{{{3}}}.{{{4}}}
which transforms the IP address in an integer which is sorted but not displayed. --Lionelr 15:10, 25 February 2011 (UTC)

Returning to the natural order of a table (and bumping a discussion on the need to provide for static rank columns)[edit]

[cricobr] In many sortable tables the sorts provided by the columns may not provide the information or result expected. In this situation the reader would often like to return to the natural sort order of the table: that is the sort order of the wikitext; the order in which the table appeared when the reader first entered the article. It would be neat to have a button for this. It could be added as a small button to the left of the header text for the first column, with a float-over popup with explanatory text.

I know it is possible to return to the natural sort order by reloading the page, but this is not immediately obvious. If the sort button is provided on the table, an un-sort button should be provided in the same context.

I would also like to bump up an earlier discussion about the provision of a facility for blocking the sorting of a column so that it can be used as a rank column. See: m:Help_talk:Sorting#Isolating_Columns

Cricobr 16:10, 8 June 2011 (UTC)


Numeric sorting is still wrong[edit]

Today I stumbled o http://en.wikipedia.org/wiki/List_of_countries_by_future_gross_government_debt The sorting of the number in second column ("2011") is wrong. After first click on the column header, the values are: 10.737 10.92 103.205 11.282 etc

That is obviously wrong. This is with Firefox 5.0 in Windows XP. I know there are bugs recorded about this (like https://bugzilla.wikimedia.org/show_bug.cgi?id=8115 ) but they were created 5 years ago and it still does not work. --Xerces8 14:54, 25 July 2011 (UTC)

Sort not working with data-sort-value[edit]

In the example on the help page, the sort is not working properly when data-sort-value is used. It is sorting the three names in the following order: Bianchi, Smith, and Ray. Visionholder 16:28, 14 September 2011 (UTC)

It seems the page has been updated for version 1.18, while the current version is 1.17wmf1.--Patrick (talk) 22:25, 14 September 2011 (UTC)

Changes - linking headers[edit]

Not sure exactly when, but the style of sorting in tables has changed recently. Previously it was the little box and now it is the two arrows. There is a problem however in that the whole header box becomes the button. On many tables the headers are linked to articles for one reason or another - these links show up as present but no longer works because of the changes to the table system. Can this be corrected?82.35.18.139 16:17, 5 October 2011 (UTC)

Additionally those arrows disappear, if you change the background color of the column headers via style="background:#. And furthermore, it was previously possible to sort tables by a primary and a secondary value simply by clicking the secondary first, then the primary. Now, to have the same effect, you have to hold shift while clicking them, which is quite awkward. It would be nice if this could be fixed. (79.237.171.41 21:41, 12 October 2011 (UTC))

Secondary sortkey/Stable sort[edit]

I’ve got a problem with secondary sortkey. Taking the example in section Help:Sorting#Secondary sortkey, when I click first on Currency and then on Numbers (no shift key or whatsoever) I get within number 3 the currency in the order 3.77, 2.30, 1.50, 5.50, 6.50. Sorting just the currency beforehand is right (1.50, 2.30, 3.77, 5.50, 6.50 picking up just number 3) and I would understand if it goes back to the original order 6.50, 2.30, 5.50, 3.77, 1.50. And, yes, first click on Numbers and, while holding shift, clicking on Currency works fine (i.e. 1.50, 2.30, 3.77, 5.50, 6.50), but still the above mentioned results just locks random to me. FF7 on Linux, if that’s any help. --Alexander Sommer 13:54, 21 October 2011 (UTC)

Table sorting problem[edit]

Hi. As far as I know, the rows of a sortable table should be in their natural order when elements of the column by which the table is sorted are equal. E.g. sorting by a column with the same enty in each row shouldnt change the table. Unfortunately this doesnt happen when I sort this table. It should look quite regular when sorted by column IN (inversion number), but it doesn't, because the rows with the same IN value are in a random order instead of the natural one. (In natural order the left two columns are ascending.) Greetings, Lipedia 20:35, 7 December 2011 (UTC)

It does not seem possible to preserve the original order in general, but in this case you can get the desired result by sorting by column IN and apply secondary sorting by the leftmost column; I just corrected the section on secondary sorting.--Patrick (talk) 00:07, 8 December 2011 (UTC)

"Correcting a wrongly parsed cell" data-sort-value not working?[edit]

Help:Sorting#Correcting a wrongly parsed cell doesn't seem to be working for me. The example still sort based on the first name, rather than data-sort-value. Curly Turkey 07:33, 6 February 2012 (UTC)

That's because of bug 31527. You can probably work around it by using the uglier jquery metadata syntax:

{|class="wikitable sortable"
!Name and Surname!!Height
|-
|class="{sort-value:'Smith'}"|John Smith||1.85
|-
|class="{sort-value:'Ray'}"|Ian Ray||1.89
|-
|class="{sort-value:'Bianchi'}"|Zachary Bianchi||1.72
|-
!Average:||1.82
|}


Name and Surname Height
John Smith 1.85
Ian Ray 1.89
Zachary Bianchi 1.72
Average: 1.82

--Tgr (talk) 08:53, 19 February 2012 (UTC)

Apparently not... --Tgr (talk) 08:57, 19 February 2012 (UTC)

Symbols/Graphics in sortable tables[edit]

Is it possible to sort graphical table content by name of used graphics? Graphic links are already sortable but unfortunately only if the link target does not exist. Thank you! --217.91.154.83 08:28, 18 June 2012 (UTC)

Decimal point problem[edit]

Is there a way to force a certain decimal (and a thousand) point?

I try to create a table with user contribution scores in translatewiki.net and since I (and every translatewiki.net user) use own language in user preferences instead of English which is the site default, then the numbers appear with Greek decimal/thousand points (which are exactly the opposite of English, i.e. "." is the thousand point and "," is the decimal one). So the table sorts as if "1000" is "1" (because in Greek it show as "1.000"). If I change my language in user prefs to English then 1.000 becomes 1,000 and table sorts correctly.

My page with table can be found here. Try to change language to Ελληνικά (Greek) to see how it behaves. Protnet (talk) 14:32, 2 February 2013 (UTC)

Persistent sort states using cookies not working[edit]

Is this script still valid in recent releases of MediaWiki? I've added it to my own wiki, but the functionality does not work. It was in a previous version, but not since we've upgraded.