Jump to content

Help talk:Sortable tables/Archive 4

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Lowercase sigmabot III (talk | contribs) at 03:49, 25 October 2021 (Archiving 1 discussion(s) from Help talk:Sorting) (bot). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
Archive 1Archive 2Archive 3Archive 4

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, 190.212.246.246 (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. 190.212.246.246 (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? 190.212.246.246 (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)

Striping

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? --93.141.92.218 (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:

CONCATENAR = CONCATENATE
SE         = IF
EXATO      = EXACTLY
ESQUERDA   = LEFT
ARRUMAR    = TIDY or TRIM
PESQUISAR  = SEARCH
DIREITA    = RIGHT
NÚM.CARACT = NUM.CHARS

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

There seems to be an easier way,using the website http://excel2wiki.net/wikipedia.php (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? 67.101.6.146 (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. 67.101.6.146 (talk) 02:56, 23 June 2011 (UTC)

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

I tried to make this list sortable but when it didn't work properly. Can someone help me?--77.49.154.248 (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:
Age
50
12
It appears that during the 1.18 release the developers switched the underlying sortable table implementation to http://tablesorter.com, 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. 69.91.29.178 (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)

Template:Static column begin. Problem with multi-row headers

This is about keeping the rows aligned between the fixed row number column and the table to its right. Please see the top table on this page:

{{Static column begin}} works easiest when there is a header column that spans all the header rows. Then I can make the header-height parameter value match up with the main table wikitext for the height of the header that spans all the rows. The header height is set high enough (270px in this case) to allow readers to expand the text size to around 133% and not break row alignment. It is easier to see this in the example and wikitext below. {{Rank}} redirects to {{Static column begin}}.

{{Rank| rows=2| header-text=Row| header-height=270px| text-align=right| caption=Incarceration rates by state.}}
{|class="wikitable nowrap sortable mw-datatable" border=1 style=text-align:right; 
|-valign=bottom
 !Jurisdiction
 !Yearend<br>2016. In<br>prison<br>or jail
 !2016<br>rate per<br>100,000<br>adults
 !2016<br>rate per<br>100,000<br>of all ages
 !rowspan=4 class=unsortable height=270px|<!--Header column is needed for {{Rank}} template.-->
|-

Template:Rank

Jurisdiction Yearend
2016. In
prison
or jail
2016
rate per
100,000
adults
2016
rate per
100,000
of all ages
US total 2,131,000 850 660
Federal 188,400 80 60
States, and
District of Columbia
1,942,600 780 600
 Alabama 40,900 1,080 840
 Alaska 4,400 800 600

|}

Problem is that this table has 4 header rows. I had to add a blank column on the right in order to have a header column that spanned (via rowspan) the 4 header rows. Can I make that column narrower, or even invisible?

Is there another way to get the static row column to perfectly align with the table rows? Can a template editor fix this in the template itself? -- Timeshifter (talk) 12:08, 25 November 2019 (UTC)

This makes it narrow: style="padding-left:0;padding-right:0;". It gets no space between the left and right border so it looks like one thick border. PrimeHunter (talk) 00:43, 26 November 2019 (UTC)
Thanks! Here is the table with that styling added to the spanning header cell:

Template:Rank

Jurisdiction Yearend
2016. In
prison
or jail
2016
rate per
100,000
adults
2016
rate per
100,000
of all ages
US total 2,131,000 850 660
Federal 188,400 80 60
States, and
District of Columbia
1,942,600 780 600
 Alabama 40,900 1,080 840
 Alaska 4,400 800 600

|}

I explained all this in the documentation:

-- Timeshifter (talk) 02:42, 26 November 2019 (UTC)

Here is a version of the table below using em units for the height parameters. It is more compact because there is no white space at the top of the headers, and because the text alone can be zoomed to very high levels without losing row alignment. See the updated documentation.

Template:Rank

Jurisdiction Yearend
2016. In
prison
or jail
2016
rate per
100,000
adults
2016
rate per
100,000
of all ages
US total 2,131,000 850 660
Federal 188,400 80 60
States, and
District of Columbia
1,942,600 780 600
 Alabama 40,900 1,080 840
 Alaska 4,400 800 600

|}

Even better is this method using header-lines=10 parameter:

Here is how that empty spanning header is formatted so that header-lines=10 works:
!rowspan=4 class=unsortable style="padding-left:0;padding-right:0;"|<br><br><br><br><br><br><br><br><br><br>

Template:Rank

Jurisdiction Yearend
2016. In
prison
or jail
2016
rate per
100,000
adults
2016
rate per
100,000
of all ages










US total 2,131,000 850 660
Federal 188,400 80 60
States, and
District of Columbia
1,942,600 780 600
 Alabama 40,900 1,080 840
 Alaska 4,400 800 600

|} -- Timeshifter (talk) 03:38, 7 December 2019 (UTC)

Default sorting on page load?

How can I define a default sort when page loads? And if there isn't any method how can one be added, I'm not asking this question for Wikipedia only Someone asked this as example: https://stackoverflow.com/questions/16140758/default-sort-column-in-wikipedia-table

Karl-police (talk) 11:55, 6 December 2019 (UTC)

Karl-police, you cannot, you have to sort it yourself. This is for performance reasons. Doing it serverside is difficult to implement, doing it client side would cause the table to dynamically change during page load, which is undesirable. —TheDJ (talkcontribs) 13:39, 6 December 2019 (UTC)
Maybe, but at the end all it should do is like the client cliks with the mouse on the header, just run that function? But that isn't possible then? Karl-police (talk) 15:48, 6 December 2019 (UTC)
It would also mean the initial table is different for users without JavaScript, or in print, in PDF conversions, when saved to disk, and so on. I think it would be too confusing. If another initial sort order is important then editors should implement it for everybody in the source. PrimeHunter (talk) 21:36, 7 December 2019 (UTC)
Karl-police and PrimeHunter: See also: Wikipedia:Village pump (technical)#Initial table sort - Check the archives once it moves there. See also: Phab:T240114: "Enhance the VisualEditor table editor to allow sorting and saving sorted content." -- Timeshifter (talk) 01:42, 9 December 2019 (UTC)
Hm? Karl-police (talk) 16:33, 14 December 2019 (UTC)
The original poster in the Village Pump discussion had the same basic question as you. The phabricator task is seeking to make the VisualEditor capable of sorting tables in the wikitext. Alphabetically or by rank. So that the initial sort is changed more easily. -- Timeshifter (talk) 22:10, 14 December 2019 (UTC)

Incorrect BC/AD date sorting?

I came to this page to look up how to properly sort BC/AD dates. I followed the example exactly and my dates didn't sort properly, at which point I realized that the dates on this page don't sort properly either. Anybody know what's up? Yuliya (talk) 19:57, 2 January 2020 (UTC)

@Yuliyag: Which table are you talking about? For me works both the two tables in #Before year 100. Any date format and the second and fourth in #Year, month, day. Using numbers. ISO date (the other two are said to be broken, so I haven’t tried them), in Firefox (68.3) as well as in Chromium (v73). —Tacsipacsi (talk) 23:08, 2 January 2020 (UTC)
@Tacsipacsi:I'm using Chrome. The section I am looking at is called "Numeric sort for BC/AD years". Instead of sorting large BC -> small BC -> small AD -> large AD, it seems to sort small BC -> large BC -> small AD -> large AD. Yuliya (talk) 18:06, 3 January 2020 (UTC)
@Yuliyag: I put a slightly modified version of the table in my sandbox (permalink). Do you see a different result when sorting? The issue might be related to the fact that the wikitext has a non-breaking space (U+00A0) in the {{Hs}} for 500 BC. Johnuniq (talk) 03:07, 4 January 2020 (UTC)
Ignore that. There is a problem which I'm scratching my head over. Unfortunately when I simplify the table the problem goes away. Johnuniq (talk) 04:20, 4 January 2020 (UTC)

I fixed the example in my sandbox (permalink). It shows that the trick to force numeric sorting of the date column does not work. Perhaps it once did, but it does not now. Sorting the Number and Date columns should give the same order. In the first table (using Help:Sorting), it fails. The second table shows the approved method using data-sort-type="number". @WOSlinker: You understand this stuff much more than me. Do you agree that my sandbox shows the information in the current Help:Sorting is wrong and should be updated per my sandbox? Johnuniq (talk) 06:08, 4 January 2020 (UTC)

Yes, your sandbox looks correct. There is also Template:Date table sorting which can be used to generate the sort keys. -- WOSlinker (talk) 09:25, 4 January 2020 (UTC)

@Timeshifter: Do you agree that the "example in my sandbox" linked just above shows that Help:Sorting#Numeric sort for BC/AD years is incorrect? You have done most recent editing to the page. Do you want to fix it? Johnuniq (talk) 05:54, 5 January 2020 (UTC)

As far as I can remember I didn't create or edit the section of Help:Sorting in question. I tried looking at it and your sandbox, but I haven't spent the time to figure out everything. I am working on other things right now, and it may be a long time before I have time for this. -- Timeshifter (talk) 08:28, 5 January 2020 (UTC)
OK, no problem. I might fix it but likewise that could take some time. Johnuniq (talk) 09:07, 5 January 2020 (UTC)

Since I started all this, I could edit. I don't do much of it, but I think I understand what is to be done. The organization of that particular section does not make sense to me, it should be folded into the rest of the dates and they already cover how to do this. Also, the table used as an example is already fixed in the article it was taken from, so I think it would be sufficient to list it as an additional example in the dates section. Yuliya (talk) 20:28, 6 January 2020 (UTC)

Date sorting problems

According to the "Month, Day and Year" and "Day, Month and Year" subsections of the "Date sorting problems" this help page, all the tables shown there should sort properly. In reality they don't. The first two tables of both subsections actually sort alphabetically on the name of the month when using the sort button. I've included a screen shot to illustrate this.Tvx1 22:22, 11 February 2020 (UTC)

Tvx1, it works for me. What browser do you use, and what are your languages settings ? —TheDJ (talkcontribs) 22:40, 11 February 2020 (UTC)
i'm pretty sure your interface language isn't set to english, and then it will use non-english names of the month to attempt the matching with. This is a known problem. —TheDJ (talkcontribs) 23:00, 11 February 2020 (UTC)
@TheDJ: Do you mean the Internationalisation Language setting at Special:Preferences? Mine is set to en - English and the sorting does not work for me. I was about to post an example showing that using the crazy date format at meta:Help:Sorting#Forcing the sort mode for a column works but I'll leave that for now until the language issue is clarified. Johnuniq (talk) 02:56, 12 February 2020 (UTC)
Sorting works for me with en but not with other languages like fr. Does the en link sort wrong for you after you have clicked the column heading? PrimeHunter (talk) 03:25, 12 February 2020 (UTC)
I clicked the column heading to sort the columns and I did that for each table at Help:Sorting#Month, day, and year. However, I must have had a brain failure because it is working now. Without your uselang links, and with your en link, when the column heading on the last table shows ▲ I see the following which is in correct ascending order by date:
January 7, 1999
December 5, 1999
May 14, 2004
August 4, 2004
Actually, all four of the tables sort correctly. I knew that I had to enable scripting for the sorting to work but maybe some glitch occurred with that, or maybe I'm nuts:( Johnuniq (talk) 04:12, 12 February 2020 (UTC)
@TheDJ:, you're right. My interface language is set to my native Dutch. When I switch to English the sorting works fine.Tvx1 18:58, 12 February 2020 (UTC)
It seems worth a mention so I have added Help:Sorting#Month names with:
All sorting involving month names may fail for registered users who have changed the default language setting "en - English" at Special:Preferences. It affects relatively few users and can be ignored.
There are possible fixes like using month numbers or sort keys but I don't think we should bother with that. PrimeHunter (talk) 19:58, 12 February 2020 (UTC)

# query

Hi all, a quick question if that's OK. In a text column, what should the entry #6 sort as? As if it were "number six"? Just "six"? Or something else entirely?

Thanks in advance! -- ChrisTheDude (talk) 09:49, 27 March 2020 (UTC)

I would sort it as "6". I guess this is about #7 at List of Top Country Albums number ones of 1986#Chart history. PrimeHunter (talk) 14:16, 27 March 2020 (UTC)
Yeah that's the one. Don't know why I typed #6 above - brain fart, clearly ;-) -- ChrisTheDude (talk) 14:32, 27 March 2020 (UTC)

Mobile Sorting

Sortable tables work on my desktop computer, but when I view them with the Wikipedia app, I'm unable to sort. Is this something that Wiki-markup teams are working on, or am I not using the correct Wiki-markup for my sortable tables?Comm260 ncu (talk) 22:03, 29 June 2020 (UTC)

Same here. I think it is just a limitation of the app. phab:T181452 seems rather old. — GhostInTheMachine talk to me 23:00, 29 June 2020 (UTC)

The main sortable table in this article seems to have been bolloxed for something like 10 years. I've tried to figure it out, but couldn't find a simple fix. Could someone with more experience with these sortable tables please help sort it out? Skyerise (talk) 22:00, 5 September 2020 (UTC)

parameters and auto-sorting tables

What do the 'create', 'order', 'numeric', and 'ascending'/'descending' parameters and more mean, how do they function, and how do I use 'colspan' and 'rowspan', and use multiple headers or place headers in different locations on Module:AutosortTable, and how do I auto-sort tables and use the 'create', 'order', 'numeric', and 'ascending'/'descending' and the other parameters on tables? -- PK2 (talk) 22:07, 21 August 2020 (UTC)

PK2, I don't think Module:AutosortTable is really being used much, if at all. See: "What links here":
Special:WhatLinksHere/Module:AutosortTable
--Timeshifter (talk) 03:53, 23 August 2020 (UTC)
PK2. There is more discussion at Help talk:Table. --Timeshifter (talk) 06:43, 6 September 2020 (UTC)

Trouble with currency sorting

I can't get Lists of institutions of higher education by endowment size#All others over US$ 1 billion to function. I'm not the best at tables/sorting; could someone help? {{u|Sdkb}}talk 21:07, 21 September 2020 (UTC)