Help talk:Sortable tables: Difference between revisions
Timeshifter (talk | contribs) →Sorting not working with complex headers: chart wikitext shown |
Thanatos666 (talk | contribs) →Sortable table not sortable when not logged in: new section |
||
Line 689: | Line 689: | ||
::Thanks for the help. [[User:Julianhall|Julianhall]] ([[User talk:Julianhall|talk]]) 11:04, 4 June 2013 (UTC) |
::Thanks for the help. [[User:Julianhall|Julianhall]] ([[User talk:Julianhall|talk]]) 11:04, 4 June 2013 (UTC) |
||
== Sortable table not sortable when not logged in == |
|||
See [[Net international investment position]].</br> |
|||
Am I the only one who's having this problem with this table (tested in 3 different browsers)?</br> |
|||
If not so (or in either case) could someone please explain why is this happening and how to fix it?</br> |
|||
Thanx.[[User:Thanatos666|Thanatos]]|[[User talk:Thanatos666|talk]] 23:49, 28 June 2013 (UTC) |
Revision as of 23:49, 28 June 2013
![]() | Wikipedia Help NA‑class | ||||||
|
Index
|
||||
Examples BROKEN
In current page as of 31 July 2012, all except three sort as text, even though many of them are labeled numerical. The three that sort as currency are the ones with $, €, and £. The ¥ sorts as text. I have verified this behavior on Windows 7 Professional running IE9 and Chrome20. NONE of the examples sorts numerically. I've submitted this as a bug as well. — Preceding unsigned comment added by Mwengler (talk • contribs) 18:22, 31 July 2012 (UTC)
Help!!!!
I have started a wikitable using this format and I'm way over my head now. I want to display the endorsements for presidential candidates in the GOP 2012 race. Check it here Endorsements for the Republican Party presidential primaries, 2012 Unfortunately, the numbers are easier to place than the names. I want to put the names in collapsible rows so people can read the numbers and verify the endorsements by checking a row below. Please help. :-< --Screwball23 talk 02:58, 27 October 2011 (UTC)
Firstly descending
I think that my question is very simple but I couldn't find the answer myself... Is it possible to add some parameter that with one click table would be sorted in a descending order? Niktute (talk) 22:43, 30 November 2011 (UTC)
- I do not understand. Is there a particular table you are trying to do this on? Can you link to it? Maybe a sandbox page on one of your user subpages. User:Niktute/Sandbox2
- Columns are sorted by clicking the sorting icon. It alternates between ascending and descending. So sometimes it takes 2 clicks. --Timeshifter (talk) 10:24, 1 December 2011 (UTC)
- Yes, now it takes two clicks and it works very well... But I was interested maybe it's possible to set some parameter (because ususaly there is one) that I would get the same result with one click?
- i.e. if the table is about the number of victories for some players, then ascending order is not realy interesting. Niktute (talk) 21:26, 6 December 2011 (UTC)
- Like Timeshifter, I do not understand the question. If the natural order of a table is descending by victories, creating the table that way seems the simplest solution. -- Michael Bednarek (talk) 03:00, 7 December 2011 (UTC)
- I think I understand the question and — if I do — it is whether there is an option to control whether a given column of a table is in ascendending or descending order when the page loads. — Robert Greer (talk) 03:13, 7 December 2011 (UTC)
- Like Timeshifter, I do not understand the question. If the natural order of a table is descending by victories, creating the table that way seems the simplest solution. -- Michael Bednarek (talk) 03:00, 7 December 2011 (UTC)
- I made table sortable because there are a lot of columns that may be interesting to sort by. So, initialy I sorted my table by one column and users themselves can sort by others... now for some columns ir takes one click to make an "interesting" sorting but for other columns user needs to click twice. As I said, it's not a problem but it would be more elegant if I can set a pereferable order of sorting. Niktute (talk) 11:03, 7 December 2011 (UTC)
There is a problem while sorting the "HS" column in this article. A few en-dashes come before "0". I'm unable to figure out the problem. Any help will be much appreciated. —Commander (Ping me) 17:15, 3 January 2012 (UTC)
- I think the asterisks/stars (*) beside some of the entries in that column are causing the problem. What is the * for (I can't seem to find a footnote to match it)? Cheers! Facts707 (talk) 19:52, 14 February 2012 (UTC)
- On closer look, it looks like the problem has already been solved. Facts707 (talk) 20:03, 14 February 2012 (UTC)
Can anyone fix List of countries by net international investment position?
Hi, all. I can't seem to get the table at List of countries by net international investment position to order by the "NIIP in % GDP" column as numeric - it always sorts it as characters instead.
All the entries in that column are numeric. Some have a leading plus sign, leading minus, and/or a leading zero, and many have references. But this should not bother the numeric sorting.
Any help would be greatly appreciated! Thanks! Facts707 (talk) 19:49, 14 February 2012 (UTC)
- It's the references. These are not numeric data, so cause the cells in which they are placed to be considered as text; and so the column as a whole is sorted as text. --Redrose64 (talk) 20:23, 14 February 2012 (UTC)
Sorting latitude/longitude
I was working with List of maria on the Moon. Is there any reasonable way to sort latitude and longitude numerically instead of alphabetically? For example, getting it to treat °N as a negative number and °S as positive so the list would start with the northernmost entry and end with the most southerly. Thanks! Aubri (talk) 18:52, 21 March 2012 (UTC)
- You might try to manually enter appropriate sort terms as non-displaying data. I have used the template {{Hs}} for this; there may be others. I would enter every latitude/longitude value in the following fashion:
{| class="wikitable sortable" ! Latin name ! Lat. ! Long. |- | [[Mare Anguis]] |align="right"|{{Hs|-226}} 22.6° N |align="right"|{{Hs|677}} 67.7° E |- | [[Mare Australe]] |align="right"|{{Hs|389}} 38.9° S |align="right"|{{Hs|930}} 93.0° E |- | [[Mare Cognitum]] |align="right"|{{Hs|100}} 10.0° S |align="right"|{{Hs|-231}} 23.1° W |- | [[Mare Crisium]] |align="right"|{{Hs|-170}} 17.0° N |align="right"|{{Hs|591}} 59.1° E |}
Latin name | Lat. | Long. |
---|---|---|
Mare Anguis | 22.6° N | 67.7° E |
Mare Australe | 38.9° S | 93.0° E |
Mare Cognitum | 10.0° S | 23.1° W |
Mare Crisium | 17.0° N | 59.1° E |
- Good luck. -- Michael Bednarek (talk) 10:00, 22 March 2012 (UTC)
Rowspan
I was trying to use a sortable table with one of the headers extending the length of the table. Here is the table: User:B2project/sandbox2
I'd like to keep the table sortable so I can change the order to determine leaders and would like to keep the break in it to clean up the table but I can't seem to get the header row to extend the rest of the table. Does anyone know if this is possible? Any help would be appreciated. Thanks.
♣ B2project ♣(Talk) 23:18, 16 April 2012 (UTC)
- The table is sortable, but dunno why, but the "sorting symbol" is not displayed, simply click next to the cell description and it sorts correctly. I will dig around if I can find the problem why this symbol is not displayed correctly. mabdul 20:09, 1 May 2012 (UTC)
- As noted above at #Styles in headers break sorting?, the workaround is to use 'background-color' instead of 'background', but this only works for the red cells, the arrows are the same black color as the black background you are using. Perhaps change from black to something dark instead? Elizium23 (talk) 20:42, 1 May 2012 (UTC)
Sorting missing values to be at end both ascending and descending
I see this was answered a couple of years ago, but in case anything has changed I'll ask again:
- is there a way to make a particular row sort to the bottom on a particular column both when the sort is ascending and when it's descending?
I want to include a "X see Y" crossref in column 1, which is a list of names of hills where just a couple have two names, but I then don't want "X" to have any content in the other cols and want it to sort down to the bottom. Can it be done? (The Outlying Fells of Lakeland, "Cartmel Fell see Raven's Barrow", if you're interested in the exact example). PamD 14:31, 2 May 2012 (UTC)
- To do that you'd need to ensure that it has both the highest value of the set and the lowest value. Unless every value in the set is identical, this is a logical impossibility. --Redrose64 (talk) 17:53, 2 May 2012 (UTC)
Sorting section replaced
I've replaced the section "Initial alphabetical sort versus initial sort by rank order" because it was suggesting people remove rank columns and sort lists alphabetically, because it would make the list easier to update. This is inappropriate as it suggests removing a useful feature for readers in order to accommodate to editors. I have instead put together a how-to on updating lists sorted by rank. Pristino (talk) 11:25, 7 June 2012 (UTC)
- And I reverted your removal of longstanding info. Feel free to create a new section on maintaining rank order. --Timeshifter (talk) 12:28, 7 June 2012 (UTC)
- And in the process you removed what I had just added. I've since restored that information without removing yours, even though I disagree with it. Pristino (talk) 00:36, 8 June 2012 (UTC)
- It can be difficult and time consuming to figure out which edits to revert. Or to go back to an old revision, copy wikitext, and paste in the new page. Maybe if I had more time available yesterday I might have done that. --Timeshifter (talk) 07:30, 8 June 2012 (UTC)
- And in the process you removed what I had just added. I've since restored that information without removing yours, even though I disagree with it. Pristino (talk) 00:36, 8 June 2012 (UTC)
Sortable table issues
Hi, I'm having some issues with a sortable table that I'm working on here. It looks nice, but it doesn't sort! I also tried this, which looks good at the beginning, but once it's sorted, the pictures move with the Snake River row and mess up the formatting. Anyway, what I'm trying to do is have a functional sortable table with images on the right side that don't move at all. Any thoughts? Thanks, LittleMountain5 14:58, 6 July 2012 (UTC)
- I don't think it's possible (or desirable) to have a table where one column stays static whilst the others are sorted. Having a second, parallel table springs to mind as an alternative solution but it would be ugly and I don't know if it's technically possible. If you really have to have this column of thumbnails on the right (I'm concerned that it's more decorative than informative) perhaps put them in a Template:Sidebar (or some similar template) and transclude that next to the table? bobrayner (talk) 15:17, 6 July 2012 (UTC)
- You're probably right. I'll fool around with it some more, but I'll probably end up doing something like this. Ah well, thanks. LittleMountain5 15:29, 6 July 2012 (UTC)
- Good luck. Have fun! bobrayner (talk) 17:24, 6 July 2012 (UTC)
- I used a workaround by taking the images out of the table and using two columns instead. It seems to work, but it might lead to accessibility issues down the road... we'll see. LittleMountain5 23:09, 6 July 2012 (UTC)
- Good luck. Have fun! bobrayner (talk) 17:24, 6 July 2012 (UTC)
- You're probably right. I'll fool around with it some more, but I'll probably end up doing something like this. Ah well, thanks. LittleMountain5 15:29, 6 July 2012 (UTC)
Numerical sorting and references
Currently, this help document explicitly states "References and reference notes after numbers do not break numerical sorting of a column. See: List of sovereign states by public debt.". However, when I was trying to fix a sorting issue with a table, the only way I can seem to make it work is to take out the references. The example given also doesn't actually seem to have any references. Am I missing something, or is the advice simply wrong? 80 Ursae Majoris (talk) 21:17, 16 July 2012 (UTC)
- I removed that link. It currently does not have any clickable references directly after numbers. What table are you working on? There are many things that can break numerical sorting. Do not waste your time trying to make date columns sort. That is broken last time I checked. Year-only columns will sort if done correctly. --Timeshifter (talk) 02:38, 17 July 2012 (UTC)
- References after numbers currently break numerical sorting of a column. See discussion and example farther down. I corrected the info in Help:Sorting in the section for numerical sorting problems. --Timeshifter (talk) 07:54, 28 July 2012 (UTC)
Static column limit?
I am unable to make the static column work on List of chess grandmasters - it appears to have a limit of 200? I've also posted on that template's talk page, so please rather answer there so that anyone else looking can find it one place. Greenman (talk) 21:23, 16 July 2012 (UTC)
Sorting help
The list Talk:List of college football coaches with 30 seasons has a sorting issue that I cannot seem to solve. Can someone peek at it please?--Paul McDonald (talk) 17:30, 27 July 2012 (UTC)
- Two sections up from here is a complaint that references prevent numeric sorting, and I think you are running into the same problem. The only way I could make the "Wins" column sort numerically was to remove the footnote from "Joe Paterno". I hope there's a better solution from that. -- John of Reading (talk) 20:58, 27 July 2012 (UTC)
- It looks like you are right. Compare these versions:
- Without reference in "Wins" column:
- http://en.wikipedia.org/w/index.php?title=List_of_college_football_coaches_with_30_seasons&oldid=472926090
- With reference in "Wins" column:
- http://en.wikipedia.org/w/index.php?title=List_of_college_football_coaches_with_30_seasons&oldid=504184911
- When one clicks the sort button the version with the reference does not sort correctly.
- I corrected the info in Help:Sorting in the section for numerical sorting problems. --Timeshifter (talk) 07:51, 28 July 2012 (UTC)
- Interesting, the Paterno footnotes were added after the sourt problem was detected.--Paul McDonald (talk) 18:34, 31 July 2012 (UTC)
Secondary sorting
In athletics results pages in events with multiple heats like the first table in 2009 Asian Athletics Championships – Men's 100 metres it is useful to sort the table by heats (2nd column) to see the results of each individual run but at the same time it should retain sorting by rank (1st column). Is there any way to achieve this? It should be noted that Heat 1 is always sorted this way, but in all others the sorting is semi-random. All such tables used to work properly in the past, but now they don't. Pietaster (talk) 12:28, 7 August 2012 (UTC)
- Help:Sorting#Secondary_key —TheDJ (talk • contribs) 12:42, 7 August 2012 (UTC)
Sorting tables with sort template
- Note: Moved from Wikipedia:Village pump (technical).
I thought I was getting the hang of sortable tables, but the table in User:Sphilbrick/sandbox isn't sorting the Diameter or Age columns correctly. Can anyone see what I did wrong?--SPhilbrick(Talk) 18:34, 25 August 2012 (UTC)
- I see various problems. See Help:Sorting. You will get more help though at Help talk:Sorting. --Timeshifter (talk) 18:55, 25 August 2012 (UTC)
- What, for example, did you see? I've read Help:sorting. Unless I'm missing something, that page is dated; it talks about the kludgey span style option, which I used years ago, but doesn't even mention the sort template--SPhilbrick(Talk) 19:00, 25 August 2012 (UTC)
- Try putting leading zeros into the sort value of {{sort}} to make them all 4 digit numbers. NtheP (talk) 19:24, 25 August 2012 (UTC)
- Thanks, just realized that. How crude.--SPhilbrick(Talk) 19:29, 25 August 2012 (UTC)
- See Help:Sorting#Numerical sorting problems and the last few sections of Help talk:Sorting. --Timeshifter (talk) 21:41, 25 August 2012 (UTC)
- As both columns contain ranges then they will be treated as alpha sorts and need the leading zeros. NtheP (talk) 21:49, 25 August 2012 (UTC)
- Can we move this whole discussion to Help talk:Sorting where it will help a lot more people? Also, I have no clue how to do what you are talking about with {{sort}}. I haven't studied it enough. Can you link to a page with a table with a number column with ranges that works with it? --Timeshifter (talk) 22:16, 25 August 2012 (UTC)
- I've no objection to moving this wherever you want. Sphilbrick's original example contains ranges and uses {{sort}}. NtheP (talk) 22:19, 25 August 2012 (UTC)
- Can we move this whole discussion to Help talk:Sorting where it will help a lot more people? Also, I have no clue how to do what you are talking about with {{sort}}. I haven't studied it enough. Can you link to a page with a table with a number column with ranges that works with it? --Timeshifter (talk) 22:16, 25 August 2012 (UTC)
- As both columns contain ranges then they will be treated as alpha sorts and need the leading zeros. NtheP (talk) 21:49, 25 August 2012 (UTC)
- See Help:Sorting#Numerical sorting problems and the last few sections of Help talk:Sorting. --Timeshifter (talk) 21:41, 25 August 2012 (UTC)
- Thanks, just realized that. How crude.--SPhilbrick(Talk) 19:29, 25 August 2012 (UTC)
- Try putting leading zeros into the sort value of {{sort}} to make them all 4 digit numbers. NtheP (talk) 19:24, 25 August 2012 (UTC)
- What, for example, did you see? I've read Help:sorting. Unless I'm missing something, that page is dated; it talks about the kludgey span style option, which I used years ago, but doesn't even mention the sort template--SPhilbrick(Talk) 19:00, 25 August 2012 (UTC)
(unindent). OK. I see now. A number column using {{sort}} is actually using an alphabetical sort due to the use of characters other than numbers. Thus the need for the same number of characters in the sort value throughout the column. I added some info about {{sort}} to Help:Sorting#Numerical sorting problems. I linked to this discussion. Feel free to clarify the info there, here, and in the documentation for the template: Template:Sort/doc. --Timeshifter (talk) 04:16, 28 August 2012 (UTC)
HTML5
Now that HTML5 is enabled, data-sort-value
will now work:
{|class="wikitable sortable" !Name and Surname!!Height |- |data-sort-value="Smith, John"|John Smith||1.85 |- |data-sort-value="Ray, Ian"|Ian Ray||1.89 |- |data-sort-value="Bianchi, Zachary"|Zachary Bianchi||1.72 |- !Average:||1.82 |}
Name and Surname | Height |
---|---|
John Smith | 1.85 |
Ian Ray | 1.89 |
Zachary Bianchi | 1.72 |
Average: | 1.82 |
---— Gadget850 (Ed) talk 18:26, 19 September 2012 (UTC)
- Thank you for the notification. This now resolves the issue mentioned earlier (Help talk:Sorting/Archive 4#Attribute data-sort-value). I've implemented it (again) at List of plays by Nestroy. It also seems that dates written as "dd month yyyy" are sorted properly – mirabile visu. -- Michael Bednarek (talk) 05:38, 20 September 2012 (UTC)
- What also works is
data-sort-type
btw. This forces a column, to use a specific type of sort algorithm. —TheDJ (talk • contribs) 06:14, 20 September 2012 (UTC)
- What also works is
{|class="wikitable sortable" !Name and Surname!! data-sort-type="date" | Height
Name and Surname | Height |
---|---|
Zachary Bianchi | 22-7-1956 |
Ian Ray | 14-9-1980 |
John Smith | Having text here would normally trigger alphabetic sort instead numerical |
Average: | 1.82 |
Beware though. There might still be a chance that HTML5 will be disabled, so I wouldn't start converting tables too quickly. No rush. —TheDJ (talk • contribs) 06:14, 20 September 2012 (UTC)
- Since the novel attributes are utilised by JavaScript (not directly interpreted by the browser layout engine), does that mean that
!data-sort-type
and|data-sort-value
will now work on all JavaScript-enabled browsers, even IE6+? (Assuming that HTML5 is not reverted.) — Richardguk (talk) 21:43, 20 September 2012 (UTC)
- The above sorting works with Windows XP and Internet Explorer 6. ---— Gadget850 (Ed) talk 23:36, 20 September 2012 (UTC)
(unindent). Is HTML 5 still enabled? Assuming that HTML 5 remains enabled where is there detailed info on data-sort-type?
Also on date sorting. Help:Sorting#Dates and meta:Help:Sorting#Dates have little info. meta:Help:Sorting#Dates says: "On English Wikipedias dates are treated as US-Dates (eg. month-day-year) per default." --Timeshifter (talk) 20:04, 26 September 2012 (UTC)
- Finally found it at meta:Help:Sorting:
data-sort-type
- text
- number
- date
- IPAddress
- currency
- url
- isoDate
- usLongDate
- time
- The first three are documented at meta:Help:Sorting, but I don't see them in the jquery.tablesorter.js source. But that is on SVN— I will have to poke around on GIT and see if that is the current version. Hmmmm... how do I know what version is installed? ---— Gadget850 (Ed) talk 20:49, 26 September 2012 (UTC)
- And yes, HTML5 is still enabled. ---— Gadget850 (Ed) talk 20:55, 26 September 2012 (UTC)
- Just checked the rendered HTML and that is the current version. It is based on the http://tablesorter.com code. ---— Gadget850 (Ed) talk 21:10, 26 September 2012 (UTC)
- And yes, HTML5 is still enabled. ---— Gadget850 (Ed) talk 20:55, 26 September 2012 (UTC)
Documentation
Is this ready to be included in the Help:Sorting page? Any volunteers? -- Michael Bednarek (talk) 12:20, 28 September 2012 (UTC)
- I added some info about
data-sort-type
to the section on numerical sorting problems. Much more needs to be done. I can not find much info aboutdata-sort-type
. I found some info about various forks of tablesorter:- http://tablesorter.com/docs/ - Version: 2.0.5.
- http://mottie.github.com/tablesorter/docs/ - Version: 2.4 (forked from version 2.0.5).
- I haven't read those pages in detail yet. I found this linked from there:
- That page says: "NOTE! This functionality was added in version 2.2.3 (it is not part of the original plugin)." It uses
data-sorter
in table headers at the level of the HTML. It looks like MediaWiki is usingdata-sort-type
instead. That is what I see in the source code for this page with some example tables: User:Timeshifter/Sandbox27. --Timeshifter (talk) 13:12, 29 September 2012 (UTC)- Our version is a fork of tablesorter.com btw. Just so that is clear. And yes, we use data-sort-type. —TheDJ (talk • contribs) 08:43, 22 October 2012 (UTC)
Ordinal Numbers
Is there a way to sort ordinal numbers so they appear in numerical order? Because of the addition of alpha characters, on many Category pages they appear as 10th, 100th, 101st, 102d, 11th, 1st . . . (not as 1st, 10th, 11th, 100th, 101st, 102d . . . Lineagegeek (talk) 14:14, 18 October 2012 (UTC)
- Help:Sorting is about table sorting. Category sorting is a completely different feature. See Wikipedia:Categorization#Sort keys. If all numbers are below 1000 then you can for example place a space in the sort key for two digit numbers so they sort before all 3-digit numbers. For 1-digit numbers the sort key can be the digit and nothing else if you want it listed first under the digit. You could also consider sort keys with a leading 0 so 1, 2, 3, 4, 5, 6, 7, 8, 9 are listed sequentially under the "0" heading. PrimeHunter (talk) 15:09, 18 October 2012 (UTC)
Table not sorting
The stats section of 2005 Nebraska Cornhuskers baseball team doesn't sort. Can someone fix it and tell me what I am missing. I have tried 50 different things. Thundrplaya (talk) 03:42, 25 October 2012 (UTC)
Fixed with this edit. Tables can only sort if the software knows there is a row of headers, and the headers have to be marked with exclamation marks rather than pipes. -- John of Reading (talk) 06:12, 25 October 2012 (UTC)
Problem - Sorting isn't sorting any more
The table sorting function appears to be broken. (Took me about an hour looking for where I had screwed up on a table I was editing last night before I went to look at existing articles with known sortable tables, to find that none are sortable any longer...)
André Kritzinger 14:34, 26 October 2012 (UTC)
- Looks like it's been repaired - sorting is sorting again.
André Kritzinger 17:33, 26 October 2012 (UTC)
Change sort arrow color?
Hi, Is there any way to change the sort arrow colors from the default black?
Thanks. Synthesized designs (talk) 14:58, 31 October 2012 (UTC)
- No. —TheDJ (talk • contribs) 16:43, 31 October 2012 (UTC)
Having a bit of problem with the sorting of the Album column in the table. Its not sorting alphabetically and this is after adding the {{sort}} in an attempt to force it to do so. I'm at a loss to why it is doing this, so any help/solution would be greatly appreciated. NapHit (talk) 22:52, 1 November 2012 (UTC)
- It is working okay for me. The lack of sortability on Writer(s) seems odd, but otherwise it looks good. —EncMstr (talk) 23:20, 1 November 2012 (UTC)
- Hmm its still not working for me. Everything is New is sorting above Consolers of the Lonely for instance, when it should be C first then E. NapHit (talk) 23:38, 1 November 2012 (UTC)
- Oops! You are correct: the Album is not sorting correctly. (I checked the other columns the first time, but when I saw a whole lot of numbers, I didn't check further.)
- I looked at the HTML but did not see anything amiss. I don't understand why it does not sort properly. —EncMstr (talk) 23:55, 1 November 2012 (UTC)
- Hmm its still not working for me. Everything is New is sorting above Consolers of the Lonely for instance, when it should be C first then E. NapHit (talk) 23:38, 1 November 2012 (UTC)
- Columns with numbers in the first row(s) (such as the album title "21") are assumed to be numeric, so the sorter gets confused when it finds further rows containing text.
- There is a new way to tell the table sorter what type of data a column contains: adding a
data-sort-type="..."
attribute to the column header. - I've added
data-sort-type="text"
and the sorting now seems to work. - The attribute is documented on the meta wiki at m:Help:Sorting#Sort modes. Valid values are
text
,number
,IPAddress
,currency
,url
,isoDate
,usLongDate
,date
, ortime
. - Though the new attribute is mentioned in the examples on this wiki using
data-sort-type="date"
anddata-sort-type="number"
, Help:Sorting would benefit from being updated so that readers did not have to check meta for the full list of types. - — Richardguk (talk) 02:57, 2 November 2012 (UTC)
- Thank you very much for the solution and explanation, much appreciated. NapHit (talk) 12:53, 2 November 2012 (UTC)
- Richardguk. Feel free to add additional info to Help:Sorting. Maybe you can create a section specifically about
data-sort-type="text"
and link to revisions of List of songs recorded by Adele as examples. --Timeshifter (talk) 22:32, 3 November 2012 (UTC)
- Richardguk. Feel free to add additional info to Help:Sorting. Maybe you can create a section specifically about
- Thanks for the feedback. I've had a go at tidying up and expanding the subsections within Help:Sorting#Creating sortable tables based on a simplified version of the Adele album list and the information on meta at m:Help:Sorting#Sort modes. I haven't removed most of the old workaround advice that dates from before
data-sort-type
anddata-sort-value
were available. But the old tricks are now redundant so the next step would be to remove this and make the advice more focused.
- Incidentally, experimenting with the album example showed that it requires several numeric rows at the top of the table to confuse the tablesorter into ignoring the non-numeric titles further down. If 19 and 21 had fewer songs listed at the start, the table would have sorted correctly all along! — Richardguk (talk) 02:46, 5 November 2012 (UTC)
- There is an autodetection based on the first 5 rows I believe. If there is no consistent detected datatype in the first 5 rows, then it will pick textual. Good work on cleaning up some of the help page. —TheDJ (talk • contribs) 09:57, 5 November 2012 (UTC)
- Thanks for the feedback. I've had a go at tidying up and expanding the subsections within Help:Sorting#Creating sortable tables based on a simplified version of the Adele album list and the information on meta at m:Help:Sorting#Sort modes. I haven't removed most of the old workaround advice that dates from before
I wonder whether someone could help me please with sortability on the Party column. As this is not currently sortable (it uses party colours for a more aesthetically-pleasing effect), it throws out the sortability on the other columns too. Thanks in anticipation. Steve cov (talk) 20:07, 4 November 2012 (UTC)
- Sorted.
The trick is not to merge the colour header with the party name header cell. The tablesorter javascript gets confused if the number of cells in the header is different from the number in the main table. Instead, the border between them can be hidden with CSS styling and the colour column can be made unsortable with a CSS class so that only the names column has a sort arrow and the blank header appears as a margin to the party name header:! ...previous columns here... !! class="unsortable" style="border-right:hidden;" | <!-- blank for colour --> !! Party !! ...subsequent columns here...
- (I also edited {{Party name with colour}} to make use of the new
data-sort-value
attribute described at meta:Help:Sorting#Specifying a sort key so that the colours column could be sortable in its own right. But with hindsight that's not necessary because sorting by the party name in the next column is sufficient.)
- — Richardguk (talk) 01:34, 5 November 2012 (UTC)
Modified CSS or another Chrome Issue?
Has the table been modified? It no longer seems to be acknowledging rowspan effect, so I see this, every single item separated by line, instead of what it was before, which was one single Emmy entry, Globe entry, whatever. It used to look like that link IF you sorted, but at it's default state, the rowspan was in effect. This is from List of awards and nominations received by Game of Thrones and I've seen it on other tables. Darkwarriorblake (talk) 23:34, 7 November 2012 (UTC)
- Same here with Firefox. It seems something is copying the cell data for row-spanned cells. E.g. the value "2011" should row-span 37 rows, but it actually appears in those – quite smart, in a way. I always followed the advice that sorting cannot be done on spanned rows. -- Michael Bednarek (talk) 06:51, 8 November 2012 (UTC)
- Ah now i understand.. We always did this for after an initial sort, but since recently we do a bit of 'prep' work on a table before the user ever clicks sort. This prep work includes the 'rowspan explosion'. This is an unintended side effect of a change that was made. Will file a report. —TheDJ (talk • contribs) 13:00, 8 November 2012 (UTC)
Issue with sorting numbers
I don't know if I'm just crazy and hadn't noticed before, but I created a Sales table for the Batman Death of the Family story article, and when I sort the numerical columns it is sorting by the first digit rather than the total value, so putting 50,070 higher than 63,659 or 3 after 17. Now I don't think it used to do this, am I doing something wrong or has something changed? Darkwarriorblake (talk) 14:22, 13 January 2013 (UTC)
- Have a look at it now. I added
{{nts}}
to the sales numbers, so it sorts as I would expect. —EncMstr (talk) 16:52, 13 January 2013 (UTC)
- Yeah that seems to have fixed it, I never noticed it needing htat before though, but maybe I wasn't paying attention. Thanks for that. Darkwarriorblake (talk) 17:05, 13 January 2013 (UTC)
- I added
data-sort-type="number"
to 2 column headers. That is easier than using {{nts}}
in every number cell, or using leading zeroes. See the section "Numerical sorting problems" in Help:Sorting. --Timeshifter (talk) 02:30, 15 January 2013 (UTC)
- Thanks for that Timeshifter, I was going to edit Death of the Family after I saw your edit here but you took care of it for me, thanks for the info and the fix. Darkwarriorblake (talk) 02:39, 15 January 2013 (UTC)
Technical detials behind sorting?
I have two questions: I run a mediawiki operation and most of the sorting works properly except for dates. Dates in text form (Aug 18, 2008, or 18 Aug 2008) do not sort properly - they sort by year, but months do not appear to sort, evaen if I try forcing the type to "date" (other types work). The documentation suggests you can "now" sort by date, suggesting this was an addition. Can anyone point me to what might have been edited or fixed so that I might add such code to my wiki?
Secondy, there is an example in the documentation where it notes that if you start out with numbers, the table can get confused and think the table is "numeric". When you sort the left column, numbers drop below letters and letters don't get sorted at all. In the right column with manually setting type to "text", it is sorted alphabetically with numbers on top. Is there any way to accomplish text sorting with numbers on the bottom (i.e. the left column but with the text cells also sorted alphabetically?) - I am doing this manually with hidden sort fields (i.e. I've prepended hidden digits to any text fields) but automatically doing it would be preferable. Similarly I've prepended hidden isodates to the dates for the first issue above, but would prefer automatics.
Thanks in advance. TheHYPO (talk) 17:17, 22 January 2013 (UTC)
- Edit/update: I tried putting my dates using the template {{dtsa}} on my wiki and it still doesn't work - again, it sorts by year, but then it is subsorting by the date next instead of the month. Any suggestions on how to get date-sorting working? TheHYPO (talk) 18:13, 22 January 2013 (UTC)
- Are you using a recent version of MediaWiki? I think that the more advanced version of tablesorter was introduced only last year with 1.21, and there were a few bug fixes and improvements in subsequent WMF releases. Also, the
data-sort-type
and data-sort-value
helper attributes will only work if your wiki enables $wgHtml5
(more info at meta:Help:Sorting).
- The JavaScript is in resources/jquery/jquery.tablesorter.js, so perhaps you could edit or override that on your wiki if you wanted to change the default priority of numbers and letters. But that might complicate future upgrades. The JavaScript uses mw.config parameter
tableSorterCollation
, which is not documented on Mediawiki Wiki; the test code implies that this can be set to an array of decompositions, so possibly this could be configured to alter the alpanumeric treatment of digits; I don't know whether that would cause unwanted side-effects with numerical sorting. But I'm not an expert, so treat all these suggestions with caution!
- — Richardguk (talk) 19:49, 22 January 2013 (UTC)
Table using rowspan/colspan broken
The table at List_of_most_common_surnames_in_North_America#United_States which uses some rowspans and colspans has broken sorting. The arrows sort by the column to the left of the one you are clicking on. I assume this is a general problem for more complicated tables; is there anyone who can help sort this out? -- Beland (talk) 08:20, 7 April 2013 (UTC)
- it's probably due to the use of numeric entries, which require {{nts}} or {{ntsh}}. Frietjes (talk) 19:55, 7 April 2013 (UTC)
- I don't see how the lack of {{nts}} or {{ntsh}} could cause the sorting to go so badly wrong. A click on "Multiracial" causes the table to sort by "Asian or Pacific Highlander"! -- John of Reading (talk) 20:14, 7 April 2013 (UTC)
- you are correct. it looks like this may have partially fixed it. I will see if there is a better method using class=unsortable. Frietjes (talk) 21:16, 7 April 2013 (UTC)
- Ingenious! I'm impressed. -- John of Reading (talk) 21:35, 7 April 2013 (UTC)
Sorting not working with complex headers
Could someone please help fix a sorting issue on List of A-League honours#Summary. When you click to sort a table, it sorts the one on the left rather than the one you clicked and I'm not sure how to fix the issue. Help would be much appreciated. --2nyte (talk) 05:57, 18 April 2013 (UTC)
- same as the thread above, fixed here. Frietjes (talk) 19:45, 19 April 2013 (UTC)
- Thanks. I could not figure out either fix. I still do not understand what is going on. Is this explained in Help:Sorting? If it is, I couldn't understand it. Could you write up some info here, or in Help:Sorting? Others can also try to clarify things more simply in Help:Sorting.
- It is common to have sorting problems when there are multi-row headers. I gave up trying to combine sorting with multi-level, multi-row headers. --Timeshifter (talk) 05:03, 20 April 2013 (UTC)
- I believe this issue is that row of cells with the sort keys cannot have rowspans. So, the fix is to split the ones with rowspans into two rows, but then make them appear as if they are joined cells by removing the border between the cells. Thanks! Plastikspork (talk) 23:24, 21 April 2013 (UTC)
(unindent). I think I figured it out a little bit. Help:Sorting needs a separate section just for getting sorting to work with complex headers. There is no such section now. Maybe I will get around to it someday.
Plastikspork, I think this is what you are talking about:
Data columns
name
data
more data
cats
273
53
dogs
65
8,492
mice
1,649
548
{| class="wikitable sortable" border="1"
|-
! style="border-bottom:none" |
! colspan=2 |Data columns
|-
! style="border-top:none" |name
! data
! more data
|-
| cats
| 273
| 53
|-
| dogs
| 65
| 8,492
|-
| mice
| 1,649
| 548
|}
The key is that there are no rowspans used in the headers. This is done by giving the appearance of rowspan without actually using rowspan in the headers. CSS styling is used to hide the border between 2 cells, and thus make them look like one cell spanning 2 rows. CSS styling:
- style="border-bottom:none"
- style="border-top:none"
- Yeah this is a known issue indeed. It shouldn't be too difficult to solve, I now pointed out in the ticket where in the source code this needs to be fixed. If I can find the time I might fix it myself. —TheDJ (talk • contribs) 09:33, 25 April 2013 (UTC)
- Hmmm. Did not know it was in Bugzilla. Has sorting worked in the past when there were rowspans in the headers? --Timeshifter (talk) 10:27, 25 April 2013 (UTC)
- Perhaps with the old version of the sorter before 1.19. That one had plenty of other problems though. —TheDJ (talk • contribs) 10:54, 25 April 2013 (UTC)
- I submitted a changeset that implements this. Let's hope it doesn't break anything this time :D —TheDJ (talk • contribs) 08:06, 26 April 2013 (UTC)
- Great! Thanks. What is the status on that? --Timeshifter (talk) 20:53, 2 May 2013 (UTC)
(unindent). Here is the same chart, but using rowspan too:
name
Data columns
data
more data
cats
273
53
dogs
65
8,492
mice
1,649
548
{| class="wikitable sortable" border="1"
|-
! rowspan=2 | name
! colspan=2 | Data columns
|-
! data
! more data
|-
| cats
| 273
| 53
|-
| dogs
| 65
| 8,492
|-
| mice
| 1,649
| 548
|}
When the bugzilla:38911 fix is implemented the above chart will sort correctly. --Timeshifter (talk) 19:53, 12 June 2013 (UTC)
2013 Italian presidential election results table
I'm having some problems with the table at Italian presidential election, 2013#Results. The columns for the first three rounds of voting sort fine, but for round 4-6 it sorts numbers as text. Could someone help? Cheers, Number 57 16:00, 22 April 2013 (UTC)
- I don't know why the last 3 columns were not sorting as numbers. But I fixed them by forcing them to sort by number. I added
- data-sort-type="number" to the column headers for those columns. See Help:Sorting#Numerical sorting problems. --Timeshifter (talk) 21:03, 2 May 2013 (UTC)
Sorting broken again??
From the first section of the article: "A sortable table is identified by the arrows in one or more of its header cells."
I see NO arrows in any cells in the example tables. Clicking the header cells does NOTHING.
And yes, I have JavaScript enabled. — Preceding unsigned comment added by 74.95.43.249 (talk) 19:36, 2 May 2013 (UTC)
- They work for me. I am using Firefox 20.0.1. Maybe try another browser. --Timeshifter (talk) 20:55, 2 May 2013 (UTC)
How to make tables using increase/decrease/steady templates sort correctly?
Hello!
Besides using a hidden sort key (and risking the displayed and hidden data becoming inconsistent), is there a way to make tables using increase/decrease/steady templates sort correctly, preferably by modifying these templates so that the template user needn't be concerned with data-sort-type etc?
For example, clicking the sorting icons in the table on the right gives steady at one end, and numbers within a category are sorted in alphabetical order.
Barisan Nasional
Pakatan Rakyat
Others
Total
State
Seats
*
+/-
Seats
*
+/-
Seats
*
+/-
Seats
Johor
38
68%
12
18
32%
12
0
0%
56
Kedah
21
58%
7
15
42%
4
0
0%
2
36
Kelantan
12
27%
5
33
73%
5
0
0%
45
Malacca
21
75%
2
7
25%
2
0
0%
28
Negeri Sembilan
22
61%
1
14
39%
1
0
0%
36
Pahang
30
71%
8
12
29%
8
0
0%
42
Penang
10
25%
1
30
75%
1
0
0%
40
Perak
31
53%
3
28
47%
1
0
0%
4
59
Perlis
13
87%
2
13%
0
0%
15
Sabah
48
80%
9
11
18%
10
1
2%
1
60
Selangor
12
21%
9
44
79%
10
0
0%
56
Terengganu
17
53%
7
15
47%
7
0
0%
32
Total
275
54%
32
229
45%
41
1
0%
7
505
As an example, I've added for the 1st "+/-" column the positive/negative delta number as the 1st parameter into the templates {{Increase}}, {{Decrease}}, {{Steady}} (see their documentation), and that seems to do the trick. -- Michael Bednarek (talk) 15:52, 10 May 2013 (UTC)
- Thanks, Michael Bednarek. This means that each number is repeated, increasing the chance that someone updating one number doesn't update the other leading to inconsistency. Is there a solution without repeating numbers? cmɢʟee୯ ͡° ̮د ͡° ੭ 11:13, 13 May 2013 (UTC)
- It can't be too difficult to enhance the templates {{Increase}}, {{Decrease}} and {{Steady}} to accept a second, named, parameter, say
|out=y
, which will cause the template to emit the first, unnamed parameter. On the other hand, as those three templates are edit-protected, it might be easier to do that with the templates {{Rise}}, {{Fall}} and {{Same position}} which are not protected. I imagine something like this (without line breaks) might work:
{{#if: {{{out}}}|{{{1}}}|}}<span title="{{{1|Rise}}}">
[[File:Green Arrow Up Darker.svg|12px
|alt={{{1|Rise}}}|link=]]</span></nowiki>
- but I'm no template maven and recommend to test this in a sandbox. -- Michael Bednarek (talk) 13:43, 13 May 2013 (UTC)
Auto-ranking
The List of largest hotels in the world article is crying out for auto-ranking. In the last week, two edits have added or removed hotels towards the top of the list, which has resulted in all the other entries requiring their rank to be edited. I've searched around, and cannot find a way to add an auto-rank column to a table. Is there a way of doing it that I've missed? Can one be developed? Julianhall (talk) 11:08, 3 June 2013 (UTC)
- See the auto-ranking section of Help:Sorting. It is currently not possible to auto-rank tables. See the Bugzilla links. One can add a separate rank column, but that will not work for wide tables such as List of largest hotels in the world. The best you can do is to put wide tables in alphabetical order initially. But without a rank column. That allows people to add new entries without breaking the ranking. People will be able to sort columns in ascending or descending order, but without rank numbers. It is better than nothing, or having to manually re-number hundreds of items in a list every time an entry is added or changed. --Timeshifter (talk) 12:45, 3 June 2013 (UTC)
- Thanks for the help. Julianhall (talk) 11:04, 4 June 2013 (UTC)
Sortable table not sortable when not logged in
See Net international investment position.
Am I the only one who's having this problem with this table (tested in 3 different browsers)?
If not so (or in either case) could someone please explain why is this happening and how to fix it?
Thanx.Thanatos|talk 23:49, 28 June 2013 (UTC)