Help talk:Sortable tables/Archive 3
![]() | This is an archive of past discussions about Help:Sortable tables. Do not edit the contents of this page. If you wish to start a new discussion or revive an old one, please do so on the current talk page. |
Archive 1 | Archive 2 | Archive 3 | Archive 4 |
Can anything be done for a table like this, which spans both multiple rows and columns? I've racked my brains but could not figure anything out. This is part of a much longer table. Thanks, Abeer.ag (talk) 18:56, 21 July 2009 (UTC)
Number | Name | Year | Opposition | Location | Played | Won | Lost | Drawn |
---|---|---|---|---|---|---|---|---|
1 | CK Nayudu | 1932 | England | England | 1 | 0 | 1 | 0 |
1933/4 | England | India | 3 | 0 | 2 | 1 | ||
Total | 4 | 0 | 3 | 1 | ||||
2 | Maharajkumar of Vizianagram | 1936 | England | England | 3 | 0 | 2 | 1 |
Total | 3 | 0 | 2 | 1 | ||||
3 | Nawab of Pataudi, Sr. | 1946 | England | England | 3 | 0 | 1 | 2 |
Total | 3 | 0 | 1 | 2 | ||||
4 | Lala Amarnath | 1947/8 | Australia | Australia | 5 | 0 | 4 | 1 |
1948/9 | West Indies | India | 5 | 0 | 1 | 4 | ||
1952/3 | Pakistan | India | 5 | 2 | 1 | 2 | ||
Total | 15 | 2 | 6 | 7 | ||||
5 | Vijay Hazare | 1951/2 | England | India | 5 | 1 | 1 | 3 |
1952 | England | England | 4 | 0 | 3 | 1 | ||
1952/3 | West Indies | West Indies | 5 | 0 | 1 | 4 | ||
Total | 14 | 1 | 5 | 8 | ||||
6 | Vinoo Mankad | 1954/5 | Pakistan | Pakistan | 5 | 0 | 0 | 5 |
1958/9† | West Indies | India | 1 | 0 | 1 | 0 | ||
Total | 6 | 0 | 1 | 5 | ||||
7 | Ghulam Ahmed | 1955/6† | New Zealand | India | 1 | 0 | 0 | 1 |
1958/9 | West Indies | India | 2 | 0 | 2 | 0 | ||
Total | 3 | 0 | 2 | 1 | ||||
8 | Polly Umrigar | 1955/6 | New Zealand | India | 4 | 2 | 0 | 2 |
1956/7 | Australia | India | 3 | 0 | 2 | 1 | ||
1958/9† | West Indies | India | 1 | 0 | 0 | 1 | ||
Total | 8 | 2 | 2 | 4 | ||||
9 | Hemu Adhikari | 1958/9† | West Indian | India | 1 | 0 | 0 | 1 |
Total | 1 | 0 | 0 | 1 | ||||
10 | Datta Gaekwad | 1959 | England | England | 4 | 0 | 4 | 0 |
Total | 4 | 0 | 4 | 0 | ||||
11 | Pankaj Roy | 1959† | England | England | 1 | 0 | 1 | 0 |
Total | 1 | 0 | 1 | 0 | ||||
Number | Name | Year | Opposition | Location | Played | Won | Lost | Drawn |
12 | Gulabrai Ramchand | 1959/60 | Australia | India | 5 | 1 | 2 | 2 |
Total | 5 | 1 | 2 | 2 | ||||
13 | Nari Contractor | 1960/1 | Pakistan | India | 5 | 0 | 0 | 5 |
1961/2 | England | India | 5 | 2 | 0 | 3 | ||
1961/2† | West Indies | West Indies | 2 | 0 | 2 | 0 | ||
Total | 12 | 2 | 2 | 8 |
- According to our current conversation on irc://irc.freenode.net/mediawiki, it seems to be currently impossible to do that. You can either split your data in a few sortable lines, or develop a PHP extension to sort them in block. JackPotte (talk) 00:12, 15 October 2009 (UTC)
- I know it's not the "right" way, but my suggestion is to do it like:
Number | Name | Year | Opposition | Location | Played | Won | Lost | Drawn | |||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | CK Nayudu |
| |||||||||||||||||||||||||||
2 | Maharajkumar of Vizianagram |
|
- Well, it's not perfect, but you see what I'm trying to do ~ 10nitro (talk) 16:43, 1 November 2009 (UTC)
Help with design of a table
Some of the entries in the table at List_of_National_Treasures_of_Japan_(castles)#Treasures are too long ("construction"), that's why I would like to split it in shorter entries. How shall I do that? The first column ("name") should not be changed as it contains the official name of the structure. Preferrably I would like to have a rowspan in the first column and extra rows for the various sub-structures ("Tenshu", "Northwest Small Tower",...). The problem with this is that I would lose the sorting feature as far as I know. Is there a workaround to have rowspan and sorting or a better way to arrange the table? bamse (talk) 10:43, 3 November 2009 (UTC)
Help with Alternating Colours Feature
I would like to be able to use the alternating colours feature of this without making the tables sortable. I.e. ideally I'd like to extract the alternate colours code from the rest of the sortables code and assign it to tables via a seperate class.
Example: {|class="prettytable alternate"
Unfortunately, I am a JS novice and, even after playing around with some of the code for several days, I can't seem to get it to work. Can anyone help? —Preceding unsigned comment added by 94.195.252.155 (talk) 20:24, 13 December 2009 (UTC)
Conditional formating based on sort parameter?
I am interested in having some text in column 1 be bold depending on which of the columns are sorted.
ie: if column 2 is sorted:
one | two(sorted) | three |
---|---|---|
the end is near | 1 | c |
take your valuables | 2 | a |
spaghetti | 3 | b |
ie: and if column 3 is sorted:
one | two | three(sorted) |
---|---|---|
take your valuables | 2 | a |
spaghetti | 3 | b |
the end is near | 1 | c |
I am hoping someone has something that sounds like "if(sort=2) then(<b>valuables</b>) else(valuables)" Jrkenti (talk) 16:25, 17 December 2009 (UTC)
Sorting of numbers does not work
I am preparing a table with sortable columns here. However the "Area" column does not sort as expected by number, but by digit. How can I fix this? Do I need to add hidden sortkeys or is there a more convenient way to achieve this?bamse (talk) 10:41, 9 January 2010 (UTC)
- After several attempts, I determined it is not any one thing. At first I thought it might be the non-breaking space that {{convert}} outputs, for example, 14.5 ha, but a jerry rigged test proved that wasn't the cause. Then I thought it might be the units (ha) so I removed those, but no luck. Then it seemed like maybe the decimal point was the issue, so I removed all those—and sure enough it sorted correctly. But then adding back the units broke it again. It seems like if the column doesn't contain pure integers, sorting considers them character entities.
- With that, the most portable solution is to use the
{{sort|what you see|what it is sorted on}}
solution. I saved a working test to your page. —EncMstr (talk) 17:37, 9 January 2010 (UTC)
- Thanks a lot. bamse (talk) 17:57, 9 January 2010 (UTC)
Sorting split tables
Hi, Is there any way to sort "split tables"?
An example is given here. What I would like is that if the table is sorted by "rider", both tables are sorted, such that "Abraham Olano" is first, followed by "Aitor González", "Alberto Contador" ... and "Alexandre Vinokourov" (all from the right table), and then "Angelino Soler" (from the left table). I know it should not sort by first name but by last name, and I know how to solve it, I just haven't done this yet.
If it is possible, it needs some changes in User:EdgeNavidad/Template:Cycling past winner mid, the template that defines the head of the tables, and User:EdgeNavidad/Template:Cycling past winner mid, the template that defines where the tables are split. I think that currently it is impossible because they are two separate tables, but that is only the implementation, and may change. If it is possible to have it technically be one table, but visually "split", it is also good.--EdgeNavidad (talk) 09:00, 17 February 2010 (UTC)
Sort issue in Safari 4
While working on several Featured Lists, I've consistently had a reviewer who uses Safari expressing issues with a certain column's sort despite it working fine on IE8 and FF3+. I decided to download Safari and test it myself. The column in question contains years and year ranges (with en dash). It appears it is doing multiple sorts, with some sorts evaluating correctly while the others separate the years with en dashes.
Term |
---|
1892 |
1895–1899 |
1900 |
1901–1922 |
1923–1932 |
1933 |
1934 |
1935 |
1936–2001 |
2002 |
Well, the example above isn't having the same result as one of the articles in question as it is not sorting ascending correctly at all. Descending seems to work. Check out this article for an example.
I'm sure I could get around this by using a template like {{SortKey}}, but I don't feel I should have to. Regardless if this column is being evaluated as a number or string, it should still sort the same. I don't understand how Safari is saying that "1936–2001" is less than "1923–1932". It should the "1" in the first columns and then the "9" in the second, and then the "2" and "3" in the third and know that "2" is lower. I just don't want to have to use a template to fix something that may be a software/MediaWiki issue.—NMajdan•talk 18:23, 22 February 2010 (UTC)
- I am said "reviewer". I get problems with that example table in both directions using Mac OS X's Safari (v4.04) and would be interested in an answer so I can stop bugging our nominators over at FLC, most of whom seem to use IE or Firefox. The Rambling Man (talk) 18:33, 22 February 2010 (UTC)
- There's no fix short of using one of the {{sort}} templates. FF + IE use a string sort in most cases. Safari initially uses a numeric sort, except when it encounters the number ranges, it's obviously not a number so it does something not so good. Without convincing Safari's developers to reproduce FF behavior—and then getting all users to immediately upgrade—the only solution is to use a sort key. —EncMstr (talk) 18:44, 22 February 2010 (UTC)
- Looked into it: On the first sort, the first tablecell has a number. The script finds the number, and sorts everything with the number sorter. The numbersorter supports +- , and . besides the actual numbers. A range is NOT a number. The tablecells that were not recognized by the number sorter, get a sortkey of 0. Thus all ranges get listed at the top. Now when you reverse, the first element is a string. That makes all elements be treated as strings, and results in proper sorting (in this specific case, it would break on negative numbers or currency of course). I'm not sure why FF has no problem. —TheDJ (talk • contribs) 20:16, 22 February 2010 (UTC)
- The difference is caused due to a problem with the 'parseFloat' function of Safari. It is webkit bug 31349. It doesn't recognize non ascii characters, and instead of 'cutting off' the parsing, returns NaN, what it shouldn't do... —TheDJ (talk • contribs) 20:47, 22 February 2010 (UTC)
- Looked into it: On the first sort, the first tablecell has a number. The script finds the number, and sorts everything with the number sorter. The numbersorter supports +- , and . besides the actual numbers. A range is NOT a number. The tablecells that were not recognized by the number sorter, get a sortkey of 0. Thus all ranges get listed at the top. Now when you reverse, the first element is a string. That makes all elements be treated as strings, and results in proper sorting (in this specific case, it would break on negative numbers or currency of course). I'm not sure why FF has no problem. —TheDJ (talk • contribs) 20:16, 22 February 2010 (UTC)
- Well, bummer. If its a browser bug, than I'll workaround with templates. Thanks for the help.—NMajdan•talk 20:58, 22 February 2010 (UTC)
displaying e.g. James Harris (politician) as James Harris in sortable list?
How does one make e.g. James Harris (politician) display only as James Harris while still linking to the correct one? How does one still it sortable on lastname "Harris" only, ignoring "(politician)"? Шизомби (Sz) (talk) 04:21, 31 March 2010 (UTC)
Col span and sortable issue
Hi in looking at the work here, i was wondering how i could either make it so the "no reward" column can either:
- Be sortable as a "Z" value for all three columns in the middle while maintaining its column span. or
- Be sorted to the bottom but allowing it to still move in response to the year sorting column.
Thanks, Salavat (talk) 12:51, 4 April 2010 (UTC)
Sorting present as a year
During the FLC of List of members of the Norwegian Nobel Committee (see Wikipedia:Featured list candidates/List of members of the Norwegian Nobel Committee/archive1) a problem has arisen while trying to sort a column of years (the 'end' column), where five are listed as 'present' and sorted as {{sort|2010|present}}
. It seems to sort correctly in Firefox, Opera and IE, but not in Safari. Since this is what is holding back the FL status, perhaps someone with more expertise could take a look? Thanks, Arsenikk (talk) 11:17, 5 April 2010 (UTC)
- What's the difference between {{sort}} and {{sortkey}}? I've also received some criticism for the lack of Safari sort-support from the same person as you. Using {{sortkey}} resolved the issues I had. I have Safari for Windows on my work PC, so when I get to work in a few hours, I'll take a look.—NMajdan•talk 12:14, 5 April 2010 (UTC)
- Yes, I do check that a table sorts correctly in my (commonplace Mac OS) browser, and it's never a "criticism" more of an observation that sometimes, the assumed sorting in Internet Explorer etc doesn't necessarily read across to all other browsers. I hope we can find a suitable solution which pleases all parties. The Rambling Man (talk) 16:05, 5 April 2010 (UTC)
- Try adding the {{sort}} template to all values in the End column. I tried this here and it appears to be working in Safari on Windows.—NMajdan•talk 16:20, 5 April 2010 (UTC)
Sort a table with two rows of title
Hi i'm a french user and on fr i want to sort the following table from the second row of title. Is it really impossible or I missed something?
Dépôt | TGV Sud-Est | TGV Atlantique | TGV Réseau | TGV Duplex | TGV POS | Eurostar | Thalys | Total | ||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
bicourant | tricourant(15 kV) | postal | bicourant | Tricourant (3kV) | RD | Dasye | TGV TMST | PBA | PBKA | |||||
Technicentre Sud Est Européen (TSEE) (Villeneuve-Saint-Georges, Paris-Conflans) |
55 | 9 | 3.5 | 6 | 73 | 19 | 27 | 192.5 | ||||||
Technicentre Atlantique (Châtillon) | 105 | 35 | 140 | |||||||||||
Technicentre Le Landy | 42 | 21 | 16 | 9 | 6 | 94 | ||||||||
Technicentre Est Européen(Paris Ourcq) | 33 | 19 | 52 | |||||||||||
Technicentre de Lyon-Gerland | ||||||||||||||
Total | 97 | 9 | 3.5 | 105 | 33 | 27 | 108 | 19 | 27 | 19 | 16 | 9 | 6 | 474.5 |
--kirikou_fr (talk) 13:00, 6 April 2010 (UTC)
- Check out List of Philadelphia Flyers players, I think its doing what you are wanting to do.—NMajdan•talk 15:17, 6 April 2010 (UTC)
- Mark the top rows with class="unsortable", and the bottom rows with class="sortbottom". This works. verdy_p (talk) 13:25, 3 July 2010 (UTC)
- Note that when there are merged cells (cells using colspan>1 or rowspan>1, they behave as if they were only the cell at the top-left of the merged area; in your example you can"t sort all columns because the sort icons options are placed only on the first row, where some header cells are merged in your example. You should be able to put the sort icon on the header cells of the second row, but I don't think it's possible for now with the current Javascript. so use the second row of header to display additional grouped headers
- The effect of merged cells within the sortable rows is also currently unpredictable:
- I don't think that the javascript is able to count cells correctly for determining their effective column number when some of them are using colspan, and there's currently no support for column groups (<colgroup> in HTML).
- The effect of merged cells with rowspan>1 is also unpredictable as there's also still no support for row groups (<thead>, <tbody>, <tfoot> in HTML).
- WikiMedia should be updated, even if tables are used without the sortable option, to support the standard column groups and row groups of HTML, which are needed for accessibility as well as to simplify the style formatting. Wikimedia just supports the 3-layers model of tables in HTML3, and does not support the 6-layers model of tables in HTML4 and higher.
- The trick of using class="unsortable" for top rows, class="sortbottom" for bottom rows is still a trick and not accessible. It should be replaced by actual support of standard row groups (<thead> and <tfoot> respectively).
- And then, sorting should be able to avoid breaking <tbody> row groups everytime the header cells are in a <thead> row group; and it should stop sorting <tbody> row groups below the thead row group containing the clicked "sort icon", as soon as it detects a non-<tbody> row group.
- verdy_p (talk) 13:37, 3 July 2010 (UTC)
Enhancement request
Numeric sort should recognise a proper minus sign (or en dash) as designating a negative number, not just a hyphen. —Preceding unsigned comment added by 86.138.42.179 (talk) 03:48, 7 April 2010 (UTC)
- Numeric sort where ? —TheDJ (talk • contribs) 15:13, 17 April 2010 (UTC)
- Numeric sort applies automatically, when the Javascript detects that columns contain numeric data (it just parses the text in the first cell of the sorted column to see if it looks like valid numeric data).
- Unfortunately, it just assumes the US format for numbers, with commas just meaning a digit group separator (ignored for the purpose of sorting numeric values), and dot meaning a decimal separator. In French this is exactly the opposite (however using a dot for grouping digits is not recommanded, French prefer spaces, preferably unbreakable thin spaces, named "fine" in French typography, i.e. &nnbsp; = NARROW NON BREAKING SPACE in Unicode). verdy_p (talk) 14:02, 3 July 2010 (UTC)
- The javascript should be able to detect that this is istill numeric data, but when computing values, it should correctly make the distinction between US format "1,234,567.89" and French format "1 234 567,89" (for the same numeric value) : the US format should be assumed only if commas and dots are used simultaneously.
- But then you'll have the ambiguity of "123,456" which means 123456×100 in English, but 123456×10−3 in French.
- "123.456" is not ambiguous (it is using US format only with a decimal separator), and "123 456" is also not ambiguous (the prefered international format interpreted correctly but in US and elsewhere, with group separator as whitespace) verdy_p (talk) 14:11, 3 July 2010 (UTC)
I wonder why we would bother to scan the first entry for digits etc. Why not just pass it to parseFloat and see if it parses? I suspect that might also solve the internationalization problems. --Doradus (talk) 15:15, 19 December 2010 (UTC)
Sorting empty cells always last/first - is this possible?
While fixing the sorting for the valuation column in List of acquisitions by Oracle table, I realized that the "N/A" values should actually be treated like an empty cell. For sorting reasons however they are treated like $0 now. Is there a way to keep them always appearing after the rows with filled currency values, like a Order by with NULLS LAST in SQL? The handling of empty cells should also be better explained in the help page here. I was also wondering what sort mode is actually used if the first row cell of a sort column happens to be an empty cell? How can you enforce a specific sort mode for empty cells? --Berny68 (talk) 10:14, 17 April 2010 (UTC)
- These are all known issues of the sortable tables system. Bugzilla is full of them. —TheDJ (talk • contribs) 15:16, 17 April 2010 (UTC)
- The sort mode is based on the first non-blank element.--Patrick (talk) 15:43, 17 April 2010 (UTC)
- Careful use of the
{{sort|sort key|visible text}}
template can achieve the desired effect:
Amount Desc $18 billion Administrative $30 billion Marketing N/A Education $19 billion R&D
- Thank you for all the answers. The example doesn't show the desired effect though. N/A is shown last when Amount is sorted in ascending order, in descending order however it's shown first. I want it show up after all non-N/A rows independent of Amount sorting.--Berny68 (talk) 18:12, 17 April 2010 (UTC)
- Ah, I guess I didn't fully understand what you are asking. I've since thought about this for awhile but can't think of any way to achieve it. —EncMstr (talk) 20:07, 17 April 2010 (UTC)
Alfabetic versus numerical sorting behaviour on same data-type
Hello, on List of FC Barcelona players I've encountered an odd behaiour. One column (Apperances) sorts alfabetically, while another (Goals) sorts numerically. They contain the exact same type of data, so it's a mystery to me. Help appreciated! Sandman888 (talk) 22:17, 30 April 2010 (UTC)
- They seem to work in the same wrong way: when "N/A" is at the top they sort alphabetically. You can apply Help:Sorting#Sorting with a hidden key, choosing whether "N/A" is positioned like a very small number or like a very large one. (It is not possible to position them at the bottom regardless of ascending or descending sort order.)--Patrick (talk) 07:54, 1 May 2010 (UTC)
- I've added span style="display:none">0</span before N/A, before i had used the hs template. But it doesn't help. I'm using Safari on a Mac btw. Sandman888 (talk) 15:21, 1 May 2010 (UTC)
- you could always use the template {{sort|0|N/A}}, but then you would have to make sure that N/A is smaller then the actual zero values. Salavat (talk) 15:28, 1 May 2010 (UTC)
- Pad the numbers with the invisible character & (at least one to force alphabetic sort mode).--Patrick (talk) 22:08, 1 May 2010 (UTC)
Auto-archiving
Wd anyone mind if I sat this page up for auto-archiving as it is growing painfully long? Sandman888 (talk) 22:36, 30 April 2010 (UTC)
- I've searched and found that this page isn't in the archiving bot scope. JackPotte (talk) 16:30, 22 May 2010 (UTC)
convert and sort templates giving an alphabetical sort of numbers
I am trying to get List of protected areas of Svalbard to sort correctly. It contains a km2 and sq mi entry created with {{convert|X|km2|disp=table}}
which is mixed with emdashes, entered as {{sort|0|—}}
. The list will then typically sort alphabetically rather than numerically as a descending sort, but correctly in an ascending sort. Can someone take a look and perhaps find out what am I doing wrong? Thanks, Arsenikk (talk) 20:05, 17 May 2010 (UTC)
Double Sortable Class
I've noticed that most tables on Wikipedia articles have "wikitable sortable sortable". I copied a table over onto my wiki and it worked fine. I then just use "wikitable sortable" instead of "wikitable sortable sortable" and it still displayed the same. What is the purpose of the double mentioning of sortable? If possible could someone let me know on my talk page. Thanks Holygamer (talk) 21:55, 5 June 2010 (UTC)
- I think it is an error, and there is no difference.--Patrick (talk) 00:04, 6 June 2010 (UTC)
Problems with alpha-numerical sorting
After reading the article, I still do not understand how to make an alpha-numerical value be sorted in tables. For example, in the article, when the last row is sorted, it becomes "row 1, row 10, row 11, row 2, row 3".
Is there a way for this one to be sorted correctly? NoNews! 23:18, 2 July 2010 (UTC)
- No; this is too complex for the Javascript to infer the correct sort order. You have to help Javascript by providing hidden sort keys. verdy_p (talk) 14:14, 3 July 2010 (UTC)
- How do I do so, then? NoNews! 03:49, 4 July 2010 (UTC)
- You have to use one of these templates for each cell of the table, to force a sortingorder. —TheDJ (talk • contribs) 14:12, 14 July 2010 (UTC)
- How do I do so, then? NoNews! 03:49, 4 July 2010 (UTC)
The default sorted column in sortable table
I would like to "sort by default" for a particular column in my table by alphabetical order. Is there any shortcut to decide which column is the sorted by default. Kasaalan (talk) 12:19, 14 July 2010 (UTC)
- The coded order is the default order. There is never any automatic sorting. —TheDJ (talk • contribs) 14:13, 14 July 2010 (UTC)
- Is there a reason for this? This would really help in big tables. daviddoria (talk) 15:23, 13 August 2010 (UTC)
- agree. definitely need this — Preceding unsigned comment added by 160.79.132.254 (talk) 00:25, 20 December 2011 (UTC)
- Any update on this feature? Would be great.Mattximus (talk) 20:43, 15 April 2012 (UTC)
- agree. definitely need this — Preceding unsigned comment added by 160.79.132.254 (talk) 00:25, 20 December 2011 (UTC)
- Is there a reason for this? This would really help in big tables. daviddoria (talk) 15:23, 13 August 2010 (UTC)
Accessibility issues when implementing "rank" in a separate table
The following note was left on my talk page, along with a revert of this version of a table:
List of countries by intentional homicide rate. Sorry to undo your edit. I know it was a lot of work. But I edit the Help:Sorting page, and understand the problems fairly well that can happen with row numbering. --Timeshifter (talk) 16:28, 27 July 2015 (UTC)
I replied as follows, but decided this topic merits a broader audience.
- @Timeshifter: yes, that was a lot of work, most of which had absolutely nothing to do with row numbering. You said that "References in the chart break the row alignment between rank column and main table." I see your point, and accept that argument, but it's an incomplete argument. In fact, said alignment is already broken, and part of my reasoning for doing what I did was to fix the very problem of which you speak! Perhaps the real issue is the fragility of an implementation that uses a separate table to define a "rank" column. Frankly, from an accessibility perspective, I think that such separate-table implementations are a very bad idea that should be eliminated from Wikipedia. I apologize if those are your invention, but that's the truth.
- Please remember that not everyone is using the same device and browser that you are using. Are you aware that for every user that has their browser set with a zoom any larger than 100% (which is a very large population of users), then "rank" columns are only meaningful on very narrow tables, such as the demo tables on Help:Sorting? In real life examples with wide tables, such as List of countries by intentional homicide rate, the rank column becomes meaningless drivel the instant any row changes height due to word wrapping. For example, zoom the page to 150%, and you will see that the final rank, 218, now aligns somewhere in the middle of the table!
- By eliminating the needless "See notes below" column, it doesn't fix the problem entirely, but it narrows the table considerably, making the zoom less of an issue. Further, given the range of devices that may be used for display, articles are not supposed to be positionally "self-aware", using words like "shown below" or "on the right". There's a guideline about that somewhere, but I don't have the time to look for it right now. The use of
{{efn}}
and{{notelist}}
templates is a simple (for both editor and reader), intuitive, officially-sanctioned, and meaningful way of presenting references and notes within a table. Sprinkling some notes at the top of the table, some at the bottom of the table, and some in a superfluous column on the side is certainly not sanctioned, nor is a separate rank column.
- If you have any ideas to solve this issue, I'd love to hear it. I also suspect that we should elevate this conversation to a broader audience, like Help_talk:Sorting. In fact, don't bother replying on my page, I'll just copy/paste this over there now. —grolltech(talk) 18:47, 27 July 2015 (UTC)
- @Grolltech: What you say is true. And that is why there are some bug threads about it, one of which I started. See the thread links in the row numbering sections in Help:Sorting. Row numbering needs to become an integral part of tables via some class like class="wikitable sortable autonumber". In the meantime we are stuck with what we have.
- On List of countries by intentional homicide rate I narrowed the notes column further. I also narrowed the years column further. So the row numbering now works at a narrower screen size than before. The table is now narrower than what you got it down to. When I am at 133% zoom the row numbering breaks down for me when I go below 1280 pixels wide. Without zoom I can go down to 1152 pixels wide.
- One thing Wikipedia might do is to free up the right sidebar that shows up for some reason at some lower screen resolutions. I see now that using zoom causes the right sidebar to expand, and block table expansion. That might be something the MediaWiki developers might fix. I think it may have to do with complicated CSS, and sizes set in em units.
- By the way, one part of your solution made things worse. The superscript (of the reference notes) breaks row numbering at all screen resolutions, and not just narrower ones. --Timeshifter (talk) 03:26, 28 July 2015 (UTC)
- There are Phabricator threads asking for a table option for a fixed column, a static rank-order column, or row numbering. See phab:T42618. It supercedes phab:T42634. --Timeshifter (talk) 07:13, 15 August 2015 (UTC)
- There is a working patch. I don't know what the holdup is with the patch being implemented. See phab:T42618. --Timeshifter (talk) 12:36, 5 December 2015 (UTC)
- There are Phabricator threads asking for a table option for a fixed column, a static rank-order column, or row numbering. See phab:T42618. It supercedes phab:T42634. --Timeshifter (talk) 07:13, 15 August 2015 (UTC)
Update on wikitable caused several problems in sortable tables.
The new display of sortable buttons in column headers of a sortable table caused several good-looking tables to be ruined. Things noticed:
- Table headers having a separate row for sorting now have their main headers also have these buttons. In addition to looking redundant, these main header buttons also take up the space that was intended to be used by the other columns.
(see its effects on table examples in: Help:Sorting#In a narrow space: sorting buttons in a separate row)
- Nested tables (that are unsortable) also have these sorting buttons at their headers when they are nested inside a sortable table.
- Even table 'footers' have these up-down sorting buttons.
It appears the solution I know of is at the moment is to painstakingly add class="unsortable" to all headers (and footers) so that these sorting buttons disappear. Is there a better/easier solution than this? Sanglahi86 (talk) 18:28, 5 February 2016 (UTC)
- Looks like a bug that needs to be reported to Phabricator. I don't have time now. I don't know when I will get time. --Timeshifter (talk) 01:33, 8 February 2016 (UTC)
Handing refs on dates?
In List of Alpha Kappa Psi chapters there are a few dates that have references, so the entries in the table are like
January 5, 1900
January 6, 1900<ref>blah-blah</ref>
January 8, 1900
Any suggestions on how to handle this? Naraht (talk) 18:37, 5 July 2016 (UTC)
- try {{dts}}. Frietjes (talk) 13:12, 3 August 2016 (UTC)
- Just on the ones with refs, or do all need to be changed?Naraht (talk) 14:42, 3 August 2016 (UTC)
- Naraht, if you use {{dts}} you will probably need to change them all. if you just want to modify the rows with refs, you can try the method described in specifying a sort key for a cell. unfortunately, that does require specifying the date twice. another method would be to put the reference in its own column, but that splits the ref from the information being referenced. you could try Forcing a column to have a particular data type, but that really only works in limited situations. Frietjes (talk) 18:13, 3 August 2016 (UTC)
- Just on the ones with refs, or do all need to be changed?Naraht (talk) 14:42, 3 August 2016 (UTC)
Sort ascending/descending is backwards
Ascending sort means that the values get bigger as you go down, descending sort means the values get smaller as you go down. Currently this is reversed.[1]. — Preceding unsigned comment added by 143.48.49.193 (talk • contribs) 11:32, 4 March 2016
- You link to Sorting#Sorting information or data. I think you are referring to the tooltip on the sort button? If so, I see that the tooltip label changes depending on whether clicking it will sort the column in ascending order or descending order. So if the column is currently in ascending order, then the tooltip says "Sort descending". --Timeshifter (talk) 19:04, 4 March 2016 (UTC)
- @Timeshifter and 143.48.49.193: It wasn't just there. I just corrected Help:Sorting on Wikimedia, referring the edit summary to this that I wrote on the Talk page[2]:
- Order in the court!
- Please note the definitions of ascending and descending order:
- The order in how information is sorted or arranged, ascending order is always arranged from lowest to highest. For example, "1, 2, 3, 4, 5" and "a, b, c, d, e, f" are both arranged in ascending order.
- The order in how information is sorted or arranged, descending order is arranged from highest to lowest. For example, "5, 4, 3, 2, 1" and "e, d, c, b, a" are both arranged in a descending order.
- I would not have thought it necessary to explain this here, but see this diff.
References
- ^ "Sorting". Wikipedia. Retrieved 4 March 2016.
- ^ https://www.mediawiki.org/w/index.php?title=Help_talk:Sorting&action=submit#Order_in_the_court.21
Existing large tables
Many existing tables use sort keys. For example, the table in List of circulating currencies § List of circulating currencies by state or territory uses 309 of them (cat | grep -ci "Sort\|+"
).
Help:Sorting admonishes us that for four types of sorting modification, "This methodology is deprecated, in favor of using" data-sort-value
, data-sort-type="text"
, or both.
data-sort-value
and data-sort-type
are pretty long to type. How about equivalent abbreviations, like dst
and dsv
? And 309 is a lot of changes to make in just this table; any suggestions for automating, like a bot?
Please {{Ping}} me to discuss. --Thnidu (talk) 02:14, 4 September 2016 (UTC)
Splitting a long sortable table to display as two side-by-side sections
I am looking to make a sortable table which has a lot of rows (over 200) and instead of having it display as one long table, is there any method to have it display as two side-by-side "columns" on the page (similar to using {{colbegin}}
to split lists into multiple columns) but still have it be a single sortable table? – Lestatdelc (talk) 04:48, 17 February 2016 (UTC)
{{div col}}
with{{div col end}}
works perfectly like in this table. — Sanglahi86 (talk) 22:00, 3 December 2016 (UTC)
Sort existing table with new criteria
Sorry if this is a noob question, just wondering how do you pre-sort existing table to updated new data? see: https://en.wikipedia.org/w/index.php?title=Biathlon_World_Championships_2017_%E2%80%93_Men%27s_sprint has to be pre-ordered by rank, how do u do it? Scribble scramble (talk) 08:04, 12 February 2017 (UTC)
- Convert table to alphabetical order. Table order will not have to be changed again. --Timeshifter (talk) 23:30, 14 February 2017 (UTC)
Initial Sorting - How is it done?
There is instructions telling you that you have to sort the table before you save the page to get the default sort order you want, but nowhere does it tell how I do this. There is no "sort arrows" in the gui when you create the table. So do I need to manually move rows up and down one by one till I get it correct? Even if I only want it to be sorted by the first column? — Preceding unsigned comment added by 84.55.110.220 (talk) 12:34, 18 January 2017 (UTC)
- That phrasing in the help page is a bit misleading; "you must sort the wikitext itself in that order" means you have to create the wikitext in the required order. Sometimes an external text editor might be helpful, but there is no standard tool in the Wikipedia editing window. -- Michael Bednarek (talk) 13:06, 18 January 2017 (UTC)
- I clarified the info in that section: Help:Sorting#Initial sort order of rows. It links to more info in another section here. I clarified that section too concerning faster methods to initially sort a table. --Timeshifter (talk) 19:57, 18 January 2017 (UTC)
- Honestly, this is stupid. So there's no way to designate the initial sort order of the table, other than just the order the rows are given in the wikitext? EEng 18:18, 20 February 2017 (UTC)
- Sorting relies on client-side JavaScript. The mobile version and users without JavaScript always have the initial order and no sort arrows. It would be odd if JavaScript users saw another initial order than the permanent order for others. It would be possible to add a non-JavaScript MediaWiki feature where a table is displayed in another order than it's written but this hasn't been done. One feature I would like in the sorting is returning to the initial order after the user has sorted. This is currently only possible if one the columns sorts in the initial order. PrimeHunter (talk) 16:09, 5 March 2017 (UTC)
- Well, I'm not sure it's that much odder than all kinds of other mobile-version inconsistencies. But that's life. EEng 19:30, 5 March 2017 (UTC)
- Sorting relies on client-side JavaScript. The mobile version and users without JavaScript always have the initial order and no sort arrows. It would be odd if JavaScript users saw another initial order than the permanent order for others. It would be possible to add a non-JavaScript MediaWiki feature where a table is displayed in another order than it's written but this hasn't been done. One feature I would like in the sorting is returning to the initial order after the user has sorted. This is currently only possible if one the columns sorts in the initial order. PrimeHunter (talk) 16:09, 5 March 2017 (UTC)
Sort of the same question
In "most of" or "biggest"/"longest" (etc) types of list articles or sections, is it possible to mark a particular column as the default one, with a largest-to-smallest value already toggled?--Froglich (talk) 21:07, 10 August 2017 (UTC)
- I think the above answers your question. EEng 21:09, 10 August 2017 (UTC)
- Bleh. I penetrated the gobbledygook as far as "Honestly, this is stupid" before giving up. If the answer is a flat "no", just tell me.--Froglich (talk) 09:26, 11 August 2017 (UTC)
- Flat no. EEng 12:49, 11 August 2017 (UTC)
- Bleh. I penetrated the gobbledygook as far as "Honestly, this is stupid" before giving up. If the answer is a flat "no", just tell me.--Froglich (talk) 09:26, 11 August 2017 (UTC)
Default sortability
Is there any reason all table headers shouldn't be sortable by default? I've seen an edge case- or two where column sorting might invite undesirable results— but surely it makes more sense for editors who can foresee those problems to obviate such circumstances rather than to deny Wikipedians of a categorical improvement in the user experience.
For example, I see no reason the table at List of most expensive association football transfers should not be wholly sortable—moreover, I see no reason to force the onus of sortability on its editors(s). — Preceding unsigned comment added by Patronanejo (talk • contribs) 02:38, 24 January 2018 (UTC)
- There are many reasons to not make all tables sortable. To name a few:
- Some tables are used for layout, e.g. of images, and not for organizing information in columns. Sort arrows would be confusing there.
- Some columns become wider with sort arrows in the headings and would require horizontal scrolling on some screens to see the whole table.
- Some tables have a single already sorted column and the only thing sort arrows could do would be to revert the sort order, but the first click may do nothing.
- Some tables have columns that would make sense to sort but they would currently sort completely wrong due to missing sort keys.
- Some tables have colspans and rowspans where sorting would break the table.