Help talk:Sortable tables: Difference between revisions
Line 226: | Line 226: | ||
After reading the article, I still do not understand how to make an alpha-numerical value be sorted in tables. For example, in [[Help:Sorting#Secondary_key|the article]], when the last row is sorted, it becomes "row 1, row 10, row 11, row 2, row 3". <br>Is there a way for this one to be sorted correctly? <b><font color="#0060C0">[[User:Newfraferz87|No]]</font><font color="#6000C0">[[User talk:Newfraferz87|News]]</font><font color="008000">[[Special:Contributions/Newfraferz87|!]]</font></b> 23:18, 2 July 2010 (UTC) |
After reading the article, I still do not understand how to make an alpha-numerical value be sorted in tables. For example, in [[Help:Sorting#Secondary_key|the article]], when the last row is sorted, it becomes "row 1, row 10, row 11, row 2, row 3". <br>Is there a way for this one to be sorted correctly? <b><font color="#0060C0">[[User:Newfraferz87|No]]</font><font color="#6000C0">[[User talk:Newfraferz87|News]]</font><font color="008000">[[Special:Contributions/Newfraferz87|!]]</font></b> 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. [[User:Verdy p|verdy_p]] ([[User talk:Verdy p|talk]]) 14:14, 3 July 2010 (UTC) |
Revision as of 14:14, 3 July 2010
![]() | Wikipedia Help NA‑class | ||||||
|
Index
|
||||
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)
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)