Help talk:Sorting/Archive 4

From Wikipedia, the free encyclopedia
Jump to: navigation, search
Archive 3 Archive 4 Archive 5

Sorting issue

I have a problem sorting column called "ISO performance" at Comparison of digital single-lens reflex cameras. I tried to put space between the value and ref tag, but that did not help.--Kozuch (talk) 20:56, 29 July 2010 (UTC)

Striping issue

Does striping actually work? Is there an additional class you have to define for the table? I have tr.odd and tr.even styles set up in Mediawiki:Common.css however it doesn't seem to do anything. Also, I can't seem to find any tables that use striping to look at as an example. --Celebane (talk) 15:16, 11 August 2010 (UTC)

I found my problem. You have to set var ts_alternate_row_colors = true in wikibits.js. It is false by default. --Celebane (talk) 15:46, 11 August 2010 (UTC)

Lexical order (Greek)

When I sort by the second column (the Greek names) in Lefktro#Settlements, Agios Nikonos comes before Agios Nikolaos (but Omicron # Omega). This sorting is strange to me, because Άγιος Νικόλαος should rank before Άγιος Νίκωνος (in the Greek alphabet ο Omicron < ω Omega) - or is the Iota's diagraph (ι vs. ί after Ν) responsible for the difference? Alfie↑↓© 16:08, 21 September 2010 (UTC)

Edit: Copypasted a short example:
English Greek population
Agios Nikolaos Άγιος Νικόλαος 508
Agios Nikonos Άγιος Νίκωνος 146
Kardamyli Καρδαμύλη (Έδρα) 447
Total 1,101

Alfie↑↓© 10:44, 22 September 2010 (UTC)

It is probably the diacritic, and the fact that we don't sort lexically. We sort probably on the unicode index value of characters. —TheDJ (talkcontribs) 14:00, 22 September 2010 (UTC)
Oh yes. :-( The Iota without the Tonos is H0359 (D953) and the one with is H03AF (D943), therefore ί < ι. Bad luck. Alfie↑↓© 14:35, 22 September 2010 (UTC)
Addendum: in the German wiki I found a hint. “Special case #3: Case-Folding maps iota-subscript (U+0345 (ͅ) COMBINING GREEK YPOGEGRAMMENI) to an iota, due to the special behavior of iota-subscript, while the UCA treats iota-subscript as a regular combining mark (secondary ignorable).”. Alfie↑↓© 15:20, 22 September 2010 (UTC)
For the archive: Solved by help of de-WP. Template {{sort}} does the job. Alfie↑↓© 17:44, 22 September 2010 (UTC)

Client side JAVA?

Nice that "client side java", but the mentioned Java looks quite mediawiki specific. Just imported the table into another mediawiki site and it works, but probably only because it is in the memory of my computer? Do I have to download that specific java or link to form my mediawiki site to get it work? Thanks, (talk) 08:46, 27 September 2010 (UTC)

more sortable data in one cell

Sometimes I need several data into one field, separated by a comma or so. For example "works with" =>Adrian, Ronald, Jack. Now if I like to sort on "works with", I get it sorted on Adrian, but on Ronald and Jack nothing shows up... Actually I like the row several times here, but only when sorting on a column that can have more options at the same time. (talk) 08:57, 27 September 2010 (UTC)

Expandable fields

Like to have fixed field-width and hoover over -or similar tooltip- to show all text that is in that field. I have no idea if this is possible at present with mediawiki? (talk) 08:57, 27 September 2010 (UTC)

Lexical order (Greek) (again)

Copied from Wikipedia:Help_desk On List of fraternities and sororities in the Philippines, there is a sortable table in the section on General Fraternities and sororities. The first column is Greek Name, which for most of the groups is two, three or four greek letters. If Alphabetized on this column, first come the ones with no Greek Name, then those where the first letter is in fact a Latin Alphabetic Character. After that, it alphabetizes by the Greek Letter itself, Alpha, Beta, Gamma, etc. However even there it is screwy as it alphabetizes in order (at one point): ΑΣ, then ΑΩΒ, then, ΑΦΕ, then ΑΣΕ, and then ΑΦΙΣ. Are there multiple Unicode characters that all look like a single greek letter (say sigma) which could have been copied in to different places that are fouling up the Alphabetical order? I can go through and redo all of them from the character subset area on the edit screen, but I'd like to understand the issue first.Naraht (talk) 15:24, 7 October 2010 (UTC)

For me it sorts ΑΣ < ΑΣΕ < ΑΦΕ < ΑΦΙΣ < ΑΩΒ, which looks correct. It may be a browser issue.—Emil J. 15:42, 7 October 2010 (UTC)
I switched to IE8 (the first time I was using Chrome) and got the same order that you do on those five. Thank You, Any idea how to make it so that all browsers do it right?Naraht (talk) 17:29, 7 October 2010 (UTC)

This page is scary

I understand sorting pages is a complex subject, but this page scares the hell out of me. This does not seem to be a newbie help page, but an advanced discussion on the topic. Oh, I am still clueless how to properly sort my table numerically. If somebody could look towards improving it I am sure all newbie editors working with tables will be forever gratefull to you. Yoenit (talk) 22:06, 17 October 2010 (UTC)


This JS is not enabled on en.Wiki, thus it it not useful help. If this is intended to help those on other wikis, then it should be at Meta. There is some discussion on striping at MediaWiki talk:Common.css, but not relevant to the section on the help page. ---— Gadget850 (Ed) talk 22:35, 17 October 2010 (UTC)

Sortable by Row

Is it possible to make a table that is sortable by rows instead of columns? I.e. if you click the arrow, the table columns to be sorted based on the selected row instead of vice-versa? -- (talk) 09:22, 30 October 2010 (UTC)

Sorting Problems

I had converted this table from a standard table to a sortable table. How can I fix it so that it sorta 1-10 instead of 1, 10, 11, 2, 3 etc.? Shootmaster 44 (talk) 22:18, 13 November 2010 (UTC)

The "NR" entries force the columns to be sorted alphabetically. You thus have to fake an alphabetic sort key for the numerical entries, the easy way to do that is to use {{nts}}.—Emil J. 12:18, 15 November 2010 (UTC)

problems with sorting by dates

I'm using the sortable table class, but am having problems sorting by date. I find the instructions a little unclear; is there any format you can apply to the date so it's not linked but still sorts correctly? Thank you. --CutOffTies (talk) 01:56, 30 November 2010 (UTC)

Try using Template:Dtsh.Jason Rees (talk) 02:03, 3 December 2010 (UTC)
Thank you!! --CutOffTies (talk) 02:40, 3 December 2010 (UTC)

Explicit sort modes?

Would it be possible to add the ability to override the automatically-selected sort mode? Perhaps the column heading could be given an attribute like sortMode="numeric" that the Javascript could detect and use instead of the auto-detected mode? --Doradus (talk) 15:21, 19 December 2010 (UTC)

Attribute data-sort-value

It seems to me that the HTML attribute data-sort-value= (see mediawiki implementation) makes the hidden sort templates {{hs}} and {{hid}} obsolete. Many other templates which use <span style="display:none"> … </span>, e.g. {{Sort}}, {{Sortname}}, {{dts}} and its many siblings, should be rewritten. If this is not feasible, the use of this attribute should be explained on this help page and in the documentation of those templates, giving guidance in how to avoid the templates in many cases for the benefit of cleaner and faster code. I have successfully used this attribute for the list of plays by Nestroy. -- Michael Bednarek (talk) 12:48, 24 February 2011 (UTC)

It appears all attributes beginning with "data-*" are currently being stripped by the Wikimedia parser. This means "data-sort-value" does not work here on Wikipedia or any of the other Wikimedia projects. Witness that the example you provided doesn't work, either. - Vague | Rant 16:51, 1 August 2011 (UTC)

Reverse order a table permanently

I'm sure someone has figured out how to do this easily but I'm stumped. Take an article like Italian_Open_(tennis) and the mens singles table. It starts in the year 2011 but at wiki tennis project we want it to start in 1930. If we don't want it sortable but we want it reversed what's the easiest way to do it? If I make the table sortable and then click on year to reverse the order, that's the way I want it to look all the time. Right now I'm copying the wiki table code into MS Word, reversing it year by year by hand, and then pasting it back into the article. If it's 10 items that's no big deal but when I have tennis tournaments that go from 2011 to 1897 that's a ton of time and effort to do. I wish I could make it sortable on wiki, click the year so that it looks the way I want, and then hit edit and have it keep that new order... but wiki doesn't work that way. Has anyone got a better idea for me. Thanks. Fyunck(click) (talk) 09:18, 27 May 2011 (UTC)

[cricobr] The following are a set of steps which could help you achieve what you want. I have not explored the idea fully, or even tested the resulting output, but the steps described below should be enough for you to apply the ideas in your specific case, and for others to apply the ideas in other contexts. I'm certain none of this is new, but it seems useful and powerful enough to be worth a try in yours and other contexts.

The technique involves the intermediate use of a spreadsheet. I used the one in OpenOffice, but I'm pretty certain everything below can be reproduced in Excel as well. I also worked in the Brazilian Portuguese version of OpenOffice, so the function names used in the following formulas will need translating to the English equivalents. Still, that should be pretty obvious, for anyone with the minimum of programming experience, with a little assistance from the help in an English version of OpenOffice or Excel.

The steps:

=== Men's singles finals ===
{|class="wikitable sortable" style=font-size:90%
  • sort the table on the year to get the oldest to newest order that you want.
  • select all the data text (all the data rows and columns) in the sorted table.
  • use CTRL-C to copy.
  • open your OpenOffice|Excel Spreadsheet.
  • paste in A1 as unformatted text (you will be asked to confirm the interpretation parameters; just accept what is offered).
  • you should now find your table pasted neatly into 4 spreadsheet columns.
  • now go to the first empty cell on the first row (should be E1), and copy and paste the following as a formula:
=CONCATENAR("|-<br>| " ;A1 ; SE(EXATO(ARRUMAR(B1); "Not Held") ;" || bgcolor=#cfcfcf|1936–1949||colspan=3 align=center bgcolor=#cfcfcf|''Not Held"; CONCATENAR(" || {{flagicon|" ;ESQUERDA(ARRUMAR(B1); PESQUISAR(" "; ARRUMAR(B1)) - 1) ;"}} '''[[" ;DIREITA(ARRUMAR(B1); NÚM.CARACT(ARRUMAR(B1)) - PESQUISAR(" "; ARRUMAR(B1))) ;"]] || {{flagicon|" ;ESQUERDA(ARRUMAR(C1); PESQUISAR(" "; ARRUMAR(C1)) - 1) ;"}} [[" ;DIREITA(ARRUMAR(C1); NÚM.CARACT(ARRUMAR(C1)) - PESQUISAR(" "; ARRUMAR(C1))) ;"]] || " ;D1)))
  • check it produces a valid result; the result for E1 (1930) should be:
|-<br>| 1930 || {{flagicon|United}} '''[[States Bill Tilden]] || {{flagicon|Italy}} [[Uberto de Morpurgo]] || 6–1, 6–1, 6–2
  • select all the cells below 'E1' up to, and including, the row for 1989 (47).
  • paste the same formula.
  • now repeat for the remaining years using the following formula:
=CONCATENAR("|-<br>| [[" ;A48 ;" Internazionali BNL d'Italia – Men's Singles|" ;A48 ;"]] || {{flagicon|" ;ESQUERDA(ARRUMAR(B48); PESQUISAR(" "; ARRUMAR(B48)) - 1) ;"}} '''[[" ;DIREITA(ARRUMAR(B48); NÚM.CARACT(ARRUMAR(B48)) - PESQUISAR(" "; ARRUMAR(B48))) ;"]] || {{flagicon|" ;ESQUERDA(ARRUMAR(C48); PESQUISAR(" "; ARRUMAR(C48)) - 1) ;"}} [[" ;DIREITA(ARRUMAR(C48); NÚM.CARACT(ARRUMAR(C48)) - PESQUISAR(" "; ARRUMAR(C48))) ;"]] || " ;D48)
  • the result of the above for row 48 (1990) should be:
|-<br>| [[1990 Internazionali BNL d'Italia – Men's Singles|1990]] || {{flagicon|Austria}} '''[[Thomas Muster]] || {{flagicon|Soviet}} [[Union Andrei Chesnokov]] || 6–1, 6–3, 6–1
  • select all the generated cells in column 'E' and copy and paste them into a text editor for final editing (such as replacing the country names with flagicon codes, and fixing the entries for countries with two part names).
  • back in Wikipedia delete all the data rows of your table.
  • back in your text editor select and copy the finalised wikitext.
  • back in Wikipedia paste the new data row wikitext into your wikitext table.
  • preview your newly formatted, reordered, table.

It would be possible to write formulas which generate EXACTLY the wikitext that you want, but, as that would be pretty tiresome for a one-off case, it is probably easier to fix the final details using the search and replace facilities in a normal text editor.

Hints for translating the Portuguese formula functions:

SE         = IF

Cricobr (talk) 02:54, 9 June 2011 (UTC)

There seems to be an easier way,using the website (which is mentioned at Wikipedia:Tools#Importing (converting) content to Wikipedia (MediaWiki) format).
  • After sorting the table (class="wikitable sortable") as desired and copying the result into a spreadsheet program, copy and paste the table from that spreadsheet program into the converter Excel2Wiki and copy/paste its result back into the Wikipedia article's table. Note that sortable tables must not contain row spans. -- Michael Bednarek (talk) 05:45, 9 June 2011 (UTC)
I had tried copying it into a spreadsheet and the excell2wiki but the result looses all it flags nomenclature. It sorts it but strips it also. I'll poke around at Cricobr's fix but it looks more complicated than doing it by hand on Microsoft Word. Man... I was hoping wiki had some nice and easy fix for me. Thanks. Fyunck(click) (talk) 06:28, 9 June 2011 (UTC)
Type your data into an Excel spreadsheet and then when your finished use this excel to Wiki language converter to add all the wiki language in. This may not be a good way of doing it but its worth a shot.Jason Rees (talk) 16:44, 9 June 2011 (UTC)

Sorting ordinals in table

Sometimes editors use ordinal numbers in table columns. To make such a column always sort in the expected order, it is tempting to try {{sort}}, e.g. {{sort|1|1st}}, {{sort|2|2nd}}, {{sort|10|10th}}, {{sort|1000|1000th}}, but this didn't work when I tried it. I look at Category:Sorting templates and didn't see any obvious alternatives. Any suggestions? (talk) 02:47, 23 June 2011 (UTC) P.S. Here's a test case, with the last being the ordinal column:

Juror # Character 1954 actor 1957 actor 1997 actor 2004–2005 actor 2006–2007 actor Votes 'not guilty'
1 The jury foreman Norman Fell Martin Balsam Courtney B. Vance Mark Blum George Wendt 9th
2 An unpretentious bank clerk John Beal John Fiedler Ossie Davis Kevin Greer Todd Cerveris 5th
3 A businessman and distraught father; the antagonist Franchot Tone Lee J. Cobb George C. Scott Philip Bosco Randle Mell 12th
4 A stockbroker, unflappable and self-assured, strong and analytical Walter Abel E. G. Marshall Armin Mueller-Stahl James Rebhorn Jeffrey Hayenga 11th
5 A young man from a violent slum, a Baltimore Orioles fan Lee Phillips Jack Klugman Dorian Harewood Michael Mastro Jim Saltouros 3rd
6 A house painter, tough, principled, and respectful Bart Burns Edward Binns James Gandolfini Robert Clohessy Charles Borland 6th
7 A salesman, sports fan, indifferent to the deliberations Paul Hartman Jack Warden Tony Danza John Pankow Mark Morettini 7th
8 An architect, the first dissenter; the protagonist Robert Cummings Henry Fonda Jack Lemmon Boyd Gaines Richard Thomas 1st
9 A wise and observant elderly man Joseph Sweeney Joseph Sweeney Hume Cronyn Tom Aldredge Alan Mandell 2nd
10 A garage owner and bigot Edward Arnold Ed Begley Mykelti Williamson Peter Friedman Julian Gamble 10th
11 A watchmaker and naturalized American citizen George Voskovec George Voskovec Edward James Olmos Larry Bryggman David Lively 4th
12 A wisecracking, advertising executive William West Robert Webber William Petersen Adam Trese Craig Wroe 8th
P.S. Soon after I posted the question I tried {{sort|01|1st}}, {{sort|02|2nd}}, {{sort|10|10th}}, {{sort|1000|1000th}}, which worked. Unless there's a template that is explicitly for ordinal numbers I guess that solution is fine. (talk) 02:56, 23 June 2011 (UTC)

Including items in a 'wiki linked' column without the automatic wiki link

Sorry if the subject is confusing! I'm working on a page List of Doncaster Rovers F.C. players where the item entry is like this:
|- |align=left|Cavanagh, TommyTommy Cavanagh||IF ||1956–1959 ||119||16||124||18|| |-
The problem I have is with players who don't yet have a page. I would like their names to appear in plain unlinked text so if someone does create a page with the same name but not the same person, the link won't turn blue. I can make it eg:
|- |align=left|Cavanagh, TommyTommy Cavanagh||IF ||1956–1959 ||119||16||124||18|| |-
This would guard against this but is there any way of just keeping names as they are but in unlinked text?
Thanks! Cjwilky (talk) 16:17, 25 June 2011 (UTC)

Have you tried using the parameter |nolink=1 with {{Sortname}}? -- Michael Bednarek (talk) 05:24, 26 June 2011 (UTC)

List of trials of peers in the House of Lords

I tried to make this list sortable but when it didn't work properly. Can someone help me?-- (talk) 19:24, 14 August 2011 (UTC)

Rows in sortable tables using colspan= need special treatment; see Help:Table#Excluding rows from sorting and Help:Table#Colspan workaround. It's probably simpler to place the text in those last two rows into one row and mark it as class="sortbottom" or even have all that text outside and below the table. -- Michael Bednarek (talk) 04:58, 15 August 2011 (UTC)

Sortable table alterations?

Something has happened to the sortable table columns. They have become much wider, leading the table at Snooker world ranking points 2011/2012 to go off the side of the page. In Firefox this isn't so bad because you can at least scroll along. However, in Internet Explorer 8 it is impossible to even scroll along meaning we lose half the table. I'm sure our table isn't the only one affected on Wikipedia if the columns have been widened (which I didn't think was necessary to be honest because the chart looked better when it was fully on the page), but by not being able to scroll along in IE it has become virtually useless. It would be great if someone could address the IE issue. Betty Logan (talk) 17:04, 6 October 2011 (UTC)

Could be related to the update to 1.18 Mediawiki software. Feel free to publish an error report at the Village Pump (technical). The Rambling Man (talk) 17:07, 6 October 2011 (UTC)
OK, thanks I will do that. Betty Logan (talk) 17:09, 6 October 2011 (UTC)
I just noticed this too. For me the issue is that columns with short headers are suddenly twice as wide as before, which wastes space and looks bad:
It appears that during the 1.18 release the developers switched the underlying sortable table implementation to, which I guess has a better sorting algorithm but a worse layout. I filed a complaint at Village Pump (technical) [1]. - Morinao (talk) 20:39, 22 October 2011 (UTC)
Well, I tried. If anyone else cares, this is where I'm leaving it: [2]. - Morinao (talk) 22:38, 22 October 2011 (UTC)

"Numeric sort for BC/AD years" section's sorting not working correctly

When I try to sort the table in the "Numeric sort for BC/AD years" section on this help page by year, the ascending sort order goes like this:

  • ca.200 BC
  • c. 400 BC
  • ca.400 BC
  • ca. 500 BC
  • ca.700 BC
  • 1652
  • 1822
  • 1865
  • c. 8th century
  • c.900

(The descending order is the reverse of that). Seems that it's sorting by the hidden sort key, but using an alphabetical instead of numeric sort. I am using Firefox 3.6. (talk) 00:58, 8 October 2011 (UTC)

Not Sortable Anymore

All the sortable tables I have created will not sort anymore. Seems to have happened in the last day or two. What has happened and how can I fix it? See Fasliyev for example. Tigerboy1966 (talk) 09:34, 8 October 2011 (UTC)

You have to define the header cells with !, not |. I don't have my head in the new sorter, so take this to WP:VPT. ---— Gadget850 (Ed) talk 11:00, 8 October 2011 (UTC)
Thank you for your prompt response Gadget Tigerboy1966 (talk) 11:05, 8 October 2011 (UTC)

how do we sort numerically?

I'm confused. At List of natural satellites I placed a copy of all data in the Mean radius column in exponential form within {{Hs}}, yet it still sorts alphanumerically. I tried {{sort}}, which we use in another article, and still no go. What am I doing wrong? — kwami (talk) 13:25, 8 October 2011 (UTC)

See meta:Help:Sorting for the new sorting features. ---— Gadget850 (Ed) talk 02:08, 10 October 2011 (UTC)
Thanks. Actually, I found a work-around with the old system: just add lots of zeros in front. Took me long enough to see it! — kwami (talk) 06:31, 10 October 2011 (UTC)

Styles in headers break sorting?

I notice, trying the examples, that adding style="background:#cfcfcf;" to a header cell causes sorting to be disabled for that column.

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

although styling of cells still permits sorting

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

Is there a workaround for this, or are sortable table headers doomed to be plain? --Lexein (talk) 04:25, 16 October 2011 (UTC)

I reported it as a bug at bugzilla --Lexein (talk) 23:40, 19 October 2011 (UTC)
Update: The dev-suggested workaround is to use style="background-color:#cfcfcf" instead of "backgound" --Lexein (talk) 01:12, 18 December 2011 (UTC)

Sorting tables with multiple numbers of digits

I want to fix a table which, when sorted, sorts by the FIRST number, rather than the full number. For instance, from low to high, the table would sort as:

  • 1,000
  • 15
  • 2,000
  • 25

etc. I want it to sort by the value of the numbers instead. I am guessing that I use (ntsh), correct? littlebum2002 19:15, 19 October 2011 (UTC)

EDIT: Never mind, I am totally lost. Why does the table under Long-distance trails in the Republic of Ireland sort properly, but the table under List of NCAA football bowl records sorts in the way described earlier? I can't figure out the difference. — Preceding unsigned comment added by Littlebum2002 (talkcontribs) 19:21, 19 October 2011 (UTC)
The problem is related to the footnotes. The table correctly sorts the Losses column, but the Wins column is lexically sorted. Same is true with the Ties (correctly sorted) and Bowl Games (lexical). The distinguishing feature in both cases is that the correctly sorting columns do not have footnotes. This article uses a mechanism I have not seen on wiki before: an HTML-based linkage <sup id="inlined" class="reference">[[#noted|[d]]]</sup>. Try replacing that with the standard wiki footnote markup using <ref>...,</ref> or <ref name=.../> and see if that fixes it. If not, then an explicit sort key mechanism using one of the {{sort}} templates should work, though it is a bit harder to initially write. —EncMstr (talk) 19:36, 19 October 2011 (UTC)
Thanks, I just realized the different columns in the same article sorted differently, and was coming to comment on it when I saw your response. I had a feeling it was an error: I would see no reason why Wikipedia would default to lexical sorting on something which should obviously sort by value. let me try the reference switch and see if it works littlebum2002 19:49, 19 October 2011 (UTC)
I fixed the footnotes issue, but the table still sorts lexically on those columns. This seems odd: could it be that any footnotes in a table stops it from sorting by value? This seems like a bug of some sort. littlebum2002 21:10, 19 October 2011 (UTC)
It's working as designed. The sort mechanism bases its sorting method on the data; a value of 123<ref group=a name=y /> is not recognised as a numeric value. You have to use one of the sorting templates which create hidden sort keys. -- Michael Bednarek (talk) 03:39, 20 October 2011 (UTC)
I instead moved the notes to another column, but I have seen other pages which have this same problem that I will try to fix using the hidden keys. It makes sense that the software sees the reference tags as text behind the numbers, thus converting the table to sort lexically. It just seems that reference tags would be an exception. So it is not a bug, but IMO it is something that could and should be fixed. I don;t think every table in the encyclopedia that uses references should have to put hidden tags everywhere. I wrote a bug report, but I think I will change it into a modification request instead. littlebum2002 12:08, 20 October 2011 (UTC)