Help talk:Sortable tables: Difference between revisions
Tag: Reply |
|||
Line 641: | Line 641: | ||
:Responding late, but better late than never. @[[User:Facts707|Facts707]], {{tlx|unsorted list}} is the template you are looking for. [[User:Qwerty284651|Qwerty284651]] ([[User talk:Qwerty284651|talk]]) 05:07, 30 October 2022 (UTC) |
:Responding late, but better late than never. @[[User:Facts707|Facts707]], {{tlx|unsorted list}} is the template you are looking for. [[User:Qwerty284651|Qwerty284651]] ([[User talk:Qwerty284651|talk]]) 05:07, 30 October 2022 (UTC) |
||
::Thanks qwerty! I have added an MOS section and a couple links to make list sorting a little easier to find. |
::Thanks qwerty! I have added an MOS section [[MOS:LISTSORT]] and a couple links to make list sorting a little easier to find. |
||
::Cheers, [[User:Facts707|Facts707]] ([[User talk:Facts707|talk]]) 05:54, 30 October 2022 (UTC) |
::Cheers, [[User:Facts707|Facts707]] ([[User talk:Facts707|talk]]) 05:54, 30 October 2022 (UTC) |
||
Revision as of 05:55, 30 October 2022
![]() | Wikipedia Help NA‑class Low‑importance | |||||||||
|
Sorting years and months
Hi, I recently added a column "Duration of record" to this table. https://en.wikipedia.org/wiki/Triple_jump_world_record_progression The problem is that that column doesn't sort properly. Can anyone help? Thanks BrightOrion | talk 10:53, 6 August 2021 (UTC)
- The sort is based on the text being displayed by the templates. So 11 months ..., 20 days, 25 years ... is correct for text. You can force a numeric sort by adding a {{hidden sort key}} in front of the displayed text. Sort by the {{age in days}} should work. I have added sort keys like this
{{Hidden sort key|{{age in days|1995|8|7}}}}{{age in years and months |1995|8|7}}
, but please check that I copied the dates correctly — GhostInTheMachine talk to me 14:17, 6 August 2021 (UTC)- Thank you so much! The data seems to be correct. There's just one record that still doesn't sort properly. Adhemar da Silva (BRA) 23 July 1952--Helsinki, Finland--11 months and 26 days. This is coming up as the third longest record, when it shouldn't be. Any ideas? BrightOrion | talk 14:45, 6 August 2021 (UTC)
The value is 361 days but is being sorted as text between 3532 (9 years ...) and 3681 (10 years ...). Moving the sort values to be attributes of the table cells seems to be safer.
... ||data-sort-value="{{age in days|1952|7|23|1953|7|19}}" | {{Age in years, months and days|1952|7|23|1953|7|19}}
etc.15:29, 6 August 2021 (UTC) — GhostInTheMachine talk to me- Perfect! The table seems to be OK now. Thanks! BrightOrion | talk 16:35, 6 August 2021 (UTC)
- Thank you so much! The data seems to be correct. There's just one record that still doesn't sort properly. Adhemar da Silva (BRA) 23 July 1952--Helsinki, Finland--11 months and 26 days. This is coming up as the third longest record, when it shouldn't be. Any ideas? BrightOrion | talk 14:45, 6 August 2021 (UTC)
Applying sorting to the top row of headings, not lower ones
Hello. I regularly see sortable tables like this where the sorting arrows appear in the compressed colours row and aren't visible. Is there any way to get the sorting to apply to the top row of headers instead? Cheers, Number 57 18:32, 24 October 2021 (UTC)
- See: Help:Sorting#Background colors in sortable headers
- You can add a break in the row of colors (as below), and thus make the row taller. But there are still no sorting icons due to the problem described in the above section of Help:Sorting.
- So I changed to style="background-color:... and this put the sorting icons back in the bottom header row. That is where Mediawiki software always puts the sorting icon. I don't know how to force them to be in another header row.
- You could put the row of colors above the other header row. See farther down. I also removed the width settings in the second table. They are not helpful. Table naturally seeks least width that allows one line per row without laddering if possible.
- It is better to use the row of colors for the sorting icons. This makes the table narrower.
Province PvdA CDA VVD D'66 SGP CPN PPR GPV PSP BP DS'70 Others
Drenthe
41.5 27.1 18.2 4.4 0.4 1.2 1.4 1.8 0.6 1.3 0.6 1.5 Friesland
37.3 37.4 12.3 4.4 0.9 1.5 1.3 1.6 0.8 0.6 0.6 1.3 Gelderland
30.8 35.5 17.2 4.8 3.7 0.6 1.7 0.7 0.9 1.4 0.5 2.2 Groningen
42.4 24.3 14.4 4.4 0.3 4.3 1.9 4.0 1.3 0.7 0.6 1.4 Limburg
30.1 44.6 14.7 3.3 0.1 1.1 1.9 0.1 0.7 1.0 0.4 2.0 North Brabant
28.8 43.7 15.7 5.0 0.5 0.6 1.6 0.2 0.8 1.1 0.5 1.5 North Holland
35.4 22.9 21.7 7.3 0.5 4.5 2.1 0.4 1.5 0.6 1.2 1.9 Overijssel
31.0 39.5 13.2 4.2 2.9 1.1 1.3 2.2 0.5 1.2 0.4 2.5 South Holland
37.9 24.6 19.9 6.1 3.8 1.3 1.5 0.8 0.8 0.4 0.9 2.0 Southern IJsselmeer Polders
33.1 29.0 18.9 6.7 1.0 2.9 2.8 1.3 0.6 0.6 0.7 2.4 Utrecht
28.2 30.5 22.1 6.6 3.2 0.9 1.9 1.6 1.3 0.7 0.7 2.3 Zeeland
32.6 29.8 17.3 4.4 8.4 0.4 1.5 1.6 0.5 1.0 0.6 1.9
- ----
Province
Others PvdA CDA VVD D'66 SGP CPN PPR GPV PSP BP DS'70 Drenthe
41.5 27.1 18.2 4.4 0.4 1.2 1.4 1.8 0.6 1.3 0.6 1.5 Friesland
37.3 37.4 12.3 4.4 0.9 1.5 1.3 1.6 0.8 0.6 0.6 1.3 Gelderland
30.8 35.5 17.2 4.8 3.7 0.6 1.7 0.7 0.9 1.4 0.5 2.2 Groningen
42.4 24.3 14.4 4.4 0.3 4.3 1.9 4.0 1.3 0.7 0.6 1.4 Limburg
30.1 44.6 14.7 3.3 0.1 1.1 1.9 0.1 0.7 1.0 0.4 2.0 North Brabant
28.8 43.7 15.7 5.0 0.5 0.6 1.6 0.2 0.8 1.1 0.5 1.5 North Holland
35.4 22.9 21.7 7.3 0.5 4.5 2.1 0.4 1.5 0.6 1.2 1.9 Overijssel
31.0 39.5 13.2 4.2 2.9 1.1 1.3 2.2 0.5 1.2 0.4 2.5 South Holland
37.9 24.6 19.9 6.1 3.8 1.3 1.5 0.8 0.8 0.4 0.9 2.0 Southern IJsselmeer Polders
33.1 29.0 18.9 6.7 1.0 2.9 2.8 1.3 0.6 0.6 0.7 2.4 Utrecht
28.2 30.5 22.1 6.6 3.2 0.9 1.9 1.6 1.3 0.7 0.7 2.3 Zeeland
32.6 29.8 17.3 4.4 8.4 0.4 1.5 1.6 0.5 1.0 0.6 1.9
- --Timeshifter (talk) 00:06, 25 October 2021 (UTC)
- You can make it a non-header row with
class="sorttop"
to keep it at the top during sorting. I don't think you can combine header and non-header cells in the same row so I removed rowspan=2 from "Province" and "Others" in the below table, and added empty cells in the color row. It might look better with background color similar to the header cells and no visible border. PrimeHunter (talk) 00:11, 25 October 2021 (UTC)
Province PvdA CDA VVD D'66 SGP CPN PPR GPV PSP BP DS'70 Others Drenthe
41.5 27.1 18.2 4.4 0.4 1.2 1.4 1.8 0.6 1.3 0.6 1.5 Friesland
37.3 37.4 12.3 4.4 0.9 1.5 1.3 1.6 0.8 0.6 0.6 1.3 Gelderland
30.8 35.5 17.2 4.8 3.7 0.6 1.7 0.7 0.9 1.4 0.5 2.2 Groningen
42.4 24.3 14.4 4.4 0.3 4.3 1.9 4.0 1.3 0.7 0.6 1.4 Limburg
30.1 44.6 14.7 3.3 0.1 1.1 1.9 0.1 0.7 1.0 0.4 2.0 North Brabant
28.8 43.7 15.7 5.0 0.5 0.6 1.6 0.2 0.8 1.1 0.5 1.5 North Holland
35.4 22.9 21.7 7.3 0.5 4.5 2.1 0.4 1.5 0.6 1.2 1.9 Overijssel
31.0 39.5 13.2 4.2 2.9 1.1 1.3 2.2 0.5 1.2 0.4 2.5 South Holland
37.9 24.6 19.9 6.1 3.8 1.3 1.5 0.8 0.8 0.4 0.9 2.0 Southern IJsselmeer Polders
33.1 29.0 18.9 6.7 1.0 2.9 2.8 1.3 0.6 0.6 0.7 2.4 Utrecht
28.2 30.5 22.1 6.6 3.2 0.9 1.9 1.6 1.3 0.7 0.7 2.3 Zeeland
32.6 29.8 17.3 4.4 8.4 0.4 1.5 1.6 0.5 1.0 0.6 1.9
- PrimeHunter (talk) 00:11, 25 October 2021 (UTC)
- Another advantage of putting the sorting icons in the row of colors is that there are no links in those color cells. The link in a cell makes it difficult to quickly click the sorting cell without clicking the link. --Timeshifter (talk) 00:37, 25 October 2021 (UTC)
- I don't really see why the colors are there to begin with. They aren't accessible for screen readers and don't seem to portray any info. Given it isn't coloring data but a blank cell, it is either unnecessary or portrays info only through color. MOS:COLOR: "Ensure that color is not the only method used to communicate important information." Also, it can be argued that hiding the sortable links/arrows (e.g. 1977 Dutch general election#By province) goes against "Links should clearly be identifiable as a link to our readers." and probably MOS:EGG, which the arrows indicate sorting links when present as well as the sort order once clicked (ascending, descending or both [unsorted] arrows). Jroberson108 (talk) 06:18, 12 February 2022 (UTC)
- After a second glance, I see the colors are supposed to represent the different parties. There are so many colors that I would never use them to try and find related data in another table. I would just use the header text. Jroberson108 (talk) 06:31, 12 February 2022 (UTC)
Template to request sorting of a list?
Wondering if there is a template that can go in a list article saying something like "This list needs to be sorted" (alphabetically, alphabetically by surname and first name, by date (oldest first or newest first), etc.)? There seems to be a lot of articles that could use this, e.g. WP:Requested articles/Social sciences#Sociology people. Thanks! Facts707 (talk) 13:31, 14 April 2022 (UTC)
- Responding late, but better late than never. @Facts707,
{{unsorted list}}
is the template you are looking for. Qwerty284651 (talk) 05:07, 30 October 2022 (UTC)- Thanks qwerty! I have added an MOS section MOS:LISTSORT and a couple links to make list sorting a little easier to find.
- Cheers, Facts707 (talk) 05:54, 30 October 2022 (UTC)
Possible locale-dependent sort bug
As reported by Emanuele676 in Talk:2022 monkeypox outbreak § Changes made to the table, there seems to be a locale-dependent bug when trying to sort dates with month names in English with the user's Wikipedia language set to Italian. I cannot reproduce the problem myself. What is the best place to report this bug with the little information we have for further investigation? --Fernando Trebien (talk) 02:14, 3 June 2022 (UTC)
- It's mentioned at Help:Sorting#Month names and phab:T126744. PrimeHunter (talk) 11:47, 3 June 2022 (UTC)
- Thank you! --Fernando Trebien (talk) 16:07, 3 June 2022 (UTC)
- @PrimeHunter: Wrapping the dates with {{dts}} seems to work around the issue while increasing editing complexity. Maybe we could mention this in Help:Sorting § Month names? --Fernando Trebien (talk) 18:50, 3 June 2022 (UTC)
- I guess more than 99.9% of page views are from unregistered users or users with the default English, or British or Canadian English which also works. I don't think we should add complications. PrimeHunter (talk) 19:24, 3 June 2022 (UTC)