![]() | 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 |
Vehicle | fuel consumption | max. speed | max. power | ||||
---|---|---|---|---|---|---|---|
l/100 km | mpg (imp) | mpg (US) | km/h | mph | kW | hp | |
my car | 12 | 24 | 20 | 160 | 100 | 300 | 400 |
your car | 20 | 14 | 12 | 120 | 75 | 150 | 200 |
his car | 24 | 12 | 10 | 800 | 500 | 900 | 1,200 |
her car | 10 | 29 | 24 | 80 | 50 | 90 | 120 |
In the header, it would be nice if the sort thingies were just where they're not & not where they are. Jɪmp 08:32, 27 March 2008 (UTC)
Vehicle | l/100 km | mpg (imp) | mpg (US) | km/h | mph | kW | hp |
---|---|---|---|---|---|---|---|
my car | 12 | 24 | 20 | 160 | 100 | 300 | 400 |
your car | 20 | 14 | 12 | 120 | 75 | 150 | 200 |
his car | 24 | 12 | 10 | 800 | 500 | 900 | 1,200 |
her car | 10 | 29 | 24 | 80 | 50 | 90 | 120 |
when i have !Name!!Surname!!Height: Name is sorted by default. Now I'd like to have Surname sorted by default but still as the second column. Is it possible? --Subfader (talk) 20:35, 27 March 2008 (UTC)
function ts_makeSortable(table) { var firstRow; <b>var reverseSort = false; // flag indicating whether it should be reverse order var defaultSortAnchor = null; // anchor tag that is the sort control for the default sort column</b> if (table.rows && table.rows.length > 0) { if (table.tHead && table.tHead.rows.length > 0) { firstRow = table.tHead.rows[table.tHead.rows.length-1]; } else { firstRow = table.rows[0]; } } if (!firstRow) return; // We have a first row: assume it's the header, and make its contents clickable links for (var i = 0; i < firstRow.cells.length; i++) { var cell = firstRow.cells[i]; if ((" "+cell.className+" ").indexOf(" unsortable ") == -1) { cell.innerHTML += ' <a href="#" class="sortheader" onclick="ts_resortTable(this);return false;"><span class="sortarrow"><img src="'+ ts_image_path + ts_image_none + '" alt="↓"/></span></a>'; <b>// if the class contains "defaultsort" then sort on this column if ((" "+cell.className+" ").indexOf(" defaultsort ") > -1) { // look for the "sortheader" anchor tag and use it as the sort control var cellChildren = cell.childNodes; for( var j = 0; j < cellChildren.length; j ++ ) { if( cellChildren[j].nodeName == "A" && cellChildren[j].className == "sortheader" ) { defaultSortAnchor = cellChildren[j]; } } // if the class contains "reverse" then do a reverse sort if ((" "+cell.className+" ").indexOf(" reverse ") > -1) { reverseSort = true; } }</b> } } if (ts_alternate_row_colors) { ts_alternate(table); } <b>// if we found a default sort anchor, then do the sort if( defaultSortAnchor != null ) { ts_resortTable( defaultSortAnchor ); if( reverseSort ) { ts_resortTable( defaultSortAnchor ); } }</b> }
class="defaultsort"
in the header cell of the column you want to sort on (note: if you have this on multiple columns, the last one wins). You can also add the "reverse" class if you want it to reverse sort. This is probably an inelegant solution but it's working great for us. --Aylwyne (talk) 12:39, 6 June 2008 (UTC)
class="defaultsort"
like this: [1] but the table still does not automatically sort. Anyone know what the problem is? ќמшמφטтгמtorque 05:31, 21 August 2008 (UTC)Was this ever resolved? I would also like to define the column that is the default sort, but the above class="defaultsort"
does not work. Is this code still even there?FourTildes (talk) 22:33, 4 April 2009 (UTC)
Sorting 1,000 or so items is very slow (example: list of chess grandmasters). What method does the sorting use? Could it be faster? Bubba73 (talk), 22:35, 30 March 2008 (UTC)
Is there a way of disabling sorting on one or more columns? I see the static columns example but it's not ideal building it with two separate tables.
Anyone? Cnbrb (talk) 21:50, 9 April 2008 (UTC)
Thanks - sometimes I have a table where a reader might want to sort (say) column 1 alphabetically but subsequent columns might not be something worth sorting (e.g. a notes column). Hiding the handles would be the kind of thing I was thinking of. Cnbrb (talk) 23:15, 9 April 2008 (UTC)
I'd like to view the code for several examples used at Help:Sorting#Examples However, that page is protected from editing. Is there another location where the code is able to be viewed?
Specifically, I would like to see the wikitable code for the very last example which should show how to correctly use the "sm=n" solution for forcing numerical sort.
Quote:
Najevi (talk) 15:09, 20 April 2008 (UTC)
Ha! Found the source code at http://meta.wikimedia.orghttps://demo.azizisearch.com/lite/wikipedia/page/Help:Sorting#Examples
| style="text-align:center;" |-3°C{{smn}} | style="text-align:center;" |7°C{{smn}}
Najevi (talk) 15:21, 20 April 2008 (UTC)
In the article International wheat production statistics, years 2002-1999 work fine, while years 1998-1996 don't sort correctly. Is there any way to fix this, or is this a known "bug"? Esn (talk) 04:49, 23 April 2008 (UTC)
Try this: visit the birth control comparison table, and click the button to sort by "perfect use" rates, once. Only once. See the two "no data" items at the top, there? OK, now click it again: what's happening is that it is being sorted in a different way. I don't know the name for it, but if you look at the very top of the block of blue items in "perfect use", and start moving your eyes up line by line, you will see it go from 2 to to 20 to 26. Clearly it is being sorted in a way that make mathematical sense, but is useless for that table's intended comparison. Is there a way to make the sortable table not do this? Thanks! Whistling42 (talk) 02:45, 25 April 2008 (UTC)
{{sort|<what to sort by>|<what you see>}}
template. For the no data, I expect the sort key would be 0 (zero). —EncMstr (talk) 02:53, 25 April 2008 (UTC)On the help page says "This works in MediaWiki 1.9 and above", but on MediaWiki, the las version is: "2008-03-20: 1.12.0 quarterly release". So we should wait some month for 1.9 version, and all Mediawiki projects has a very unstable version!? —Preceding unsigned comment added by 190.18.45.41 (talk) 02:22, 14 May 2008 (UTC)
This page was very helpful! thanxArdeshire Babakan (talk) 18:10, 24 July 2008 (UTC)
This is a copy of the master help page at Meta. Do not edit this copy.
That is what I see at the top of the article Help:Sorting, followed by
Edits will be lost in the next update from the master page.
Yet I see that edits have been made to the copy and do not see any update. Is this an old out of date message? It confused me, because I first read the sort mode section (ignoring the top message out of habit) and read the "sm=n" and "m:Template:smn". I found smn does not work for me, so I look at meta:Help:Sorting , where smn mention has recently been removed. Does this mean this copy page is due an update?
Also, at the very end I see: "In particular, both the Template:Smn and the sm=n trick do not work on Wikipedia." -84user (talk) 03:56, 5 October 2008 (UTC)
This table should sort according to wikipedia's Help:Sorting but not according to according to meta:Help:Sorting (maybe because meta has removed the support for formats like 4.32×104). Today it does not sort properly.
numbers might not sort |
---|
123564589.7e12 |
9 |
4.32×104 |
-80 |
5.67 |
80 |
70 |
600 |
This table should sort according to both wikipedia and meta, and do sort for me today:
numbers should sort |
---|
123564589.7e12 |
9 |
4.32e4 |
-80 |
5.67 |
80 |
70 |
600 |
-84user (talk) 03:56, 5 October 2008 (UTC)
Sorting negative numbers seems to work when the ASCII hyphen/minus "-" (0x002D) is used. It seems that the problem may be caused by the Unicode Minus Sign "−" (0x2212). - Unimath (talk) 00:13, 11 October 2008 (UTC)
do numbers with Unicode Minus Sign sort Ok? |
---|
123564589.7e12 |
9 |
4.32e4 |
−80 |
5.67 |
80 |
70 |
600 |
How do you make a box be placed in the center? — NuclearVacuum 23:52, 27 November 2008 (UTC)
Is there a maximum on the number of rows displayed for a sorting table? I have a table with 54 rows, and only the first 50 display. Those work fine, I just need the last 4 to show. Thanks in advance, Chuckiesdad (talk) 06:13, 30 November 2008 (UTC)
It seems that if there are one or more 'non-numeric' elements in an otherwise numeric column, then it does not sort properly in firefox 3 (I tested with 3.0.4 on windows xp). You can see this on the first 'numbers' table in the Help:Sorting page (with 'ghi' as one of the elements).
Additionally, in IE6 and IE7, after the page first loads and you try to sort a table of the aforementioned description, a first click on the sort button will not properly sort the table. The second and subsequent clicks seem to work properly. You can also see this problem here: United States cities by crime rate by sorting by 'violent crime'. —Preceding unsigned comment added by Tfischer (talk • contribs) 20:51, 15 December 2008 (UTC)
I am trying to merge some wrestling title articles per a AFD discussion. The problem I am having is with the autosorting (since I am merging articles that existed just for how long they held a title with a list of chronological champions, so there has to be a way to sort based on how long they held the title). I can't seem to get it working right now. The article is List of WWE Intercontinental Champions. Could somebody experienced with autosorting take a look at it for me? TJ Spyke 05:38, 21 December 2008 (UTC)
What is the correct sorting order for words and names with diacritic letters? Various languages using the Latin alphabet sort their diacritic letters differently. In Swedish for instance, Å, Ä and Ö are the final letters of the alphabet. I assume that words with diacricits should be sorted without them, but I can't find any wikipedia rule about this. In one help page ASCII is stated to be the sorting order for strings, but that would be a bit confusing since diacritics are not placed next to their "main" letters. Mad Greg (talk) 12:15, 28 December 2008 (UTC)
I am struggling to find a solution to the sortable table at List of Calgary Flames draft picks that would allow the list to sort empty cells as being less than zero. I could use {{sort|-1| }} in each cell, but in a table of this size, it would introduce a massive amount of overhead. In fact, in testing that as a solution I found editing the table to be incredibly difficult as both IE and Firefox struggled to handle the amount of data. Unfortunately, using emdashes rather than blank cells only managed to completely break sortability. Does anyone have any suggestions on how to resolve this problem? Thanks, Resolute 23:54, 12 February 2009 (UTC)
Hi guys, is there a way to make tables in wikipedia filterable?
Similar to this: http://mguglielmi.free.fr/scripts/TableFilter/filter-sort.htm --TheBigJagielka (talk) 00:10, 30 April 2009 (UTC)
This version of Help:Sorting lacks many good updates that have been made to meta:Help:Sorting. For example, the confusing business about "sm=n" has been removed from meta's copy. Should these differing versions be synchronized now? --fjarlq (talk) 09:51, 9 May 2009 (UTC)
It seems that the method for date sorting only works for dates after 10,000 BC. How do I make a sortable column for dates before that date? In the table in question, I have dates from before 10,000 BC until around 800 AD. As the table is still in preparation, I am not sure yet what the exact dates will be. Most likely I will not have any month/day information to sort though. bamse (talk) 02:56, 13 May 2009 (UTC)
What I'd like to see is a way to pick one cell and filter OUT every row with that value in that column. This should be repeatable (same or different columns), without adding back the items filtered out (until you click refresh or something). This way you could start with a large list and gradually remove items that fail one or another criteria, until you've got the list whittled down to just the items that are truly interesting.
Ideally sorting would NOT interfere with this; it would simply sort the items you have not filtered out. —Preceding unsigned comment added by 74.166.109.199 (talk) 01:30, 21 May 2009 (UTC)
I don't understand this section at all. What is it saying? Is there something wrong with the markup or is it supposed to look like that?
Additionally, is it possible to create a table that is sorted by one of its columns by default? Shreevatsa (talk) 19:27, 25 May 2009 (UTC)
Does anyone know what is going on here? In this article, only the first five columns of the table in section 5 (history) are sortable. The last buttons cause a jump to the start of the page for some strange reason. --KarlFrei (talk) 09:53, 26 June 2009 (UTC)
sorts:
A | B |
---|---|
a | b |
c |
good code:
{| class="wikitable sortable" border="1" |- ! A ! B |- | a | b |- | c | |}
does not sort:
A | B |
---|---|
a | b |
c |
bad code (second last line is missing):
{| class="wikitable sortable" border="1" |- ! A ! B |- | a | b |- | c |}
bamse (talk) 10:58, 26 June 2009 (UTC)
As of 26 June 2009 the first sentence under the JavaScript section is confusing and doesn't appear to be proper English:
"The JavaScript code wikibits.js has on each site a copy at {{SERVER}}/skins-1.5/common/wikibits.js, on this site http://en.wikipedia.org/skins-1.5/common/wikibits.js."
Unjedai (talk) 14:57, 26 June 2009 (UTC)
I'll try again. What is the above sentence trying to say? What is the point? Is it trying to say that the JavaScript necessary to make table sorting work is installed with MediaWiki 1.9 and above versions in the {{SERVER}}/skins-1.5/common/wikibits.js directory, and that, for example on Wikipedia the URL for that is http://en.wikipedia.org/skins-1.5/common/wikibits.js? Unjedai (talk) 18:25, 23 September 2009 (UTC)
It would be much less error prone to specify the sort type in the column header itself (similar to class="unsortable"). I propose class="date|numeric|currency|string|unsortable" in the header template to override determining a sort order by parsing the first cell in the table. This would fix many, many sorting bugs due to some rows containing bad data, such as "", "123±5" or "15—17" not being seen as numeric. --IanOsgood (talk) 18:44, 5 July 2009 (UTC)
Why, on New Zealand firefighter referendum, 1995, does it sort some percentages funnily, particularly in the 'no' column? If someone could fix this or tell me how to fix it, I would be very appreciative.Adabow (talk) 01:50, 17 July 2009 (UTC)
I want to sort for the "Size column, but can't get it to happen. Here's my table:
{| class="wikitable sortable plainrowheaders" |+ Japanese serow conservation areas{{sfn|Ono|2000|p=145}} |- ! scope="col" colspan="2"|Name ! scope="col" rowspan="2"|Established ! scope="col" rowspan="2" data-sort-type="number"|Size<br />ha (acres) ! scope="col" rowspan="2"|[[Prefectures of Japan|Prefecture]](s) |- ! scope="col"|English ! scope="col"|Japanese |- !scope="row"|[[Shimokita Peninsula]] |''{{lang|ja|Shimokita Hantō}}'' |align="right"| {{dts|1981|04|}} |align="right" data-sort-value="37300"| {{convert|37300|ha|acre|abbr=values}} |align="left"|[[Aomori Prefecture|Aomori]] |- !scope="row"|[[Ōu Mountains|Kita-Ōu Mountains]] |''{{lang|ja|Kita-Ōu Sankei}}'' |align="right"| {{dts|1984|2|}} |align="right" data-sort-value="105000"| {{convert|105000|ha|acre|abbr=values}} |align="left"|{{Flatlist| *Aomori *[[Akita Prefecture|Akita]] *[[Iwate Prefecture|Iwate]]}} |- !scope="row"|{{ill|ja|Kitakami Sankei|北上山地}} |''{{lang|ja|Kitakami Sankei}}'' |align="right"| {{dts|1982|7|}} |align="right" data-sort-value="41000"| {{convert|41000|ha|acre|abbr=values}} |align="left"|Iwate |- !scope="row"|[[Ōu Mountains|Minami-Ōu Mountains]] |''{{lang|ja|Minami-Ōu Sankei}}'' |align="right"| {{dts|1984|11|}} |align="right" data-sort-value="57700"| {{convert|57700|ha|acre|abbr=values}} |align="left"|{{Flatlist| *Akita *Iwate *[[Yamagata Prefecture|Yamagata]] *[[Miyagi Prefecture|Miyagi]]}} |- !scope="row"|Asahi—[[Mount Iide|Iide]] Mountains |''{{lang|ja|Asahi—Iide Sankei}}'' |align="right"| {{dts|1985|3|}} |align="right" data-sort-value="122000"| {{convert|122000|ha|acre|abbr=values}} |align="left"|{{Flatlist| *Yamagata *[[Fukushima Prefecture|Fukushima]] *[[Niigata Prefecture|Niigata]]}} |- !scope="row"|[[Mount Echigo-Komagatake|Echigo]]—[[Mount Nikkō-Shirane|Nikkō]]—[[Mount Mikuni (Gifu)|Mikuni]] Mountains |''{{lang|ja|Echigo—Nikkō—Mikuni Sankei}}'' |align="right"| {{dts|1984|5|}} |align="right" data-sort-value="215200"| {{convert|215200|ha|acre|abbr=values}} |align="left"|{{Flatlist| *Fukushima *Niigata *[[Tochigi Prefecture|Tochigi]] *[[Gunma Prefecture|Gunma]] *[[Nagano Prefecture|Nagano]]}} |- !scope="row"|Kantō Mountains |''{{lang|ja|Kantō Sanchi}}'' |align="right"| {{dts|1984|11|}} |align="right" data-sort-value="79000"| {{convert|79000|ha|acre|abbr=values}} |align="left"|{{Flatlist| *Gunma *[[Saitama Prefecture|Saitama]] *[[Tokyo]] *[[Yamanashi Prefecture|Yamanashi]] *Nagano}} |- !scope="row"|[[Minami Alps National Park|Minami Alps]] |''{{lang|ja|Minami Arupusu}}'' |align="right"| {{dts|1980|2|}} |align="right" data-sort-value="122000"| {{convert|122000|ha|acre|abbr=values}} |align="left"|{{Flatlist| *Yamanashi *Nagano *[[Shizuoka Prefecture|Shizuoka]]}} |- !scope="row"|[[Hida Mountains|Kita Alps]] |''{{lang|ja|Kita Arupusu}}'' |align="right"| {{dts|1979|11|}} |align="right" data-sort-value="195600"| {{convert|195600|ha|acre|abbr=values}} |align="left"|{{Flatlist| *Niigata *Nagano *[[Toyama Prefecture|Toyama]] *[[Gifu Prefecture|Gifu]]}} |- !scope="row"|Shirayama |''{{lang|ja|Shirayama}}'' |align="right"| {{dts|1982|2|}} |align="right" data-sort-value="53700"| {{convert|53700|ha|acre|abbr=values}} |align="left"|{{Flatlist| *Toyama *[[Ishikawa Prefecture|Ishikawa]] *Gifu *[[Fukui Prefecture|Fukui]]}} |- !scope="row"|[[Suzuka Mountains]] |''{{lang|ja|Suzuka Sanchi}}'' |align="right"| {{dts|1983|9|}} |align="right" data-sort-value="14100"| {{convert|14100|ha|acre|abbr=values}} |align="left"|{{Flatlist| *[[Shiga Prefecture|Shiga]] *[[Mie Prefecture|Mie]]}} |- !scope="row"|[[Ibuki Mountains|Ibuki]]—[[Hira Mountains|Hira]] Mountains |''{{lang|ja|Ibuki—Hira Sankei}}'' |align="right"| {{dts|1986|3|}} |align="right" data-sort-value="67500"| {{convert|67500|ha|acre|abbr=values}} |align="left"|{{Flatlist| *Gifu *Shiga *Fukui *[[Kyoto Prefecture|Kyoto]]}} |- !scope="row"|[[Kii Mountains]] |''{{lang|ja|Kii Sankei}}'' |align="right"| {{dts|1989|7|}} |align="right" data-sort-value="79500"| {{convert|79500|ha|acre|abbr=values}} |align="left"|{{Flatlist| *Mie *[[Nara Prefecture|Nara]] *[[Wakayama Prefecture|Wakayama]]}} |- !scope="row"|Shikoku Mountains |''{{lang|ja|Shikoku Sanchi}}'' |<!-- align="right"| -->{{TBA}} |<!-- align="right"| -->{{TBA}} |align="left"|{{Flatlist| *[[Tokushima Prefecture|Tokushima]] *[[Kōchi Prefecture|Kōchi]]}} |- !scope="row"|Kyushu Mountains |''{{lang|ja|Kyushu Sanchi}}'' |<!-- align="right"| -->{{TBA}} |<!-- align="right"| -->{{TBA}} |align="left"|{{Flatlist| *[[Ōita Prefecture|Ōita]] *[[Kumamoto Prefecture|Kumamoto]] *[[Miyazaki Prefecture|Miyazaki]]}} |- |}
Name | Established | Size ha (acres) |
Prefecture(s) | |
---|---|---|---|---|
English | Japanese | |||
Shimokita Peninsula | Shimokita Hantō | April 1981 | 37,300 (92,000) | Aomori |
Kita-Ōu Mountains | Kita-Ōu Sankei | February 1984 | 105,000 (260,000) | |
Kitakami Sankei | Kitakami Sankei | July 1982 | 41,000 (100,000) | Iwate |
Minami-Ōu Mountains | Minami-Ōu Sankei | November 1984 | 57,700 (143,000) | |
Asahi—Iide Mountains | Asahi—Iide Sankei | March 1985 | 122,000 (300,000) | |
Echigo—Nikkō—Mikuni Mountains | Echigo—Nikkō—Mikuni Sankei | May 1984 | 215,200 (532,000) | |
Kantō Mountains | Kantō Sanchi | November 1984 | 79,000 (200,000) | |
Minami Alps | Minami Arupusu | February 1980 | 122,000 (300,000) |
|
Kita Alps | Kita Arupusu | November 1979 | 195,600 (483,000) | |
Shirayama | Shirayama | February 1982 | 53,700 (133,000) | |
Suzuka Mountains | Suzuka Sanchi | September 1983 | 14,100 (35,000) | |
Ibuki—Hira Mountains | Ibuki—Hira Sankei | March 1986 | 67,500 (167,000) |
|
Kii Mountains | Kii Sankei | July 1989 | 79,500 (196,000) | |
Shikoku Mountains | Shikoku Sanchi | TBA | TBA | |
Kyushu Mountains | Kyushu Sanchi | TBA | TBA |
Please help! Curly Turkey (gobble) 08:00, 10 September 2013 (UTC)
I isolated just that column, and now it is sortable. So something from the rest of the table is preventing the sorting of that column. That is as far as I have it got it so far.
Size ha (acres) |
---|
37,300 (92,000) |
105,000 (260,000) |
41,000 (100,000) |
57,700 (143,000) |
122,000 (300,000) |
215,200 (532,000) |
79,000 (200,000) |
122,000 (300,000) |
195,600 (483,000) |
53,700 (133,000) |
14,100 (35,000) |
67,500 (167,000) |
79,500 (196,000) |
TBA |
TBA |
{| class="wikitable sortable plainrowheaders" |+ Japanese serow conservation areas{{sfn|Ono|2000|p=145}} |- ! data-sort-type="number"|Size<br />ha (acres) |- |align="right" data-sort-value="37300"| {{convert|37300|ha|acre|abbr=values}} |- |align="right" data-sort-value="105000"| {{convert|105000|ha|acre|abbr=values}} |- |align="right" data-sort-value="41000"| {{convert|41000|ha|acre|abbr=values}} |- |align="right" data-sort-value="57700"| {{convert|57700|ha|acre|abbr=values}} |- |align="right" data-sort-value="122000"| {{convert|122000|ha|acre|abbr=values}} |- |align="right" data-sort-value="215200"| {{convert|215200|ha|acre|abbr=values}} |- |align="right" data-sort-value="79000"| {{convert|79000|ha|acre|abbr=values}} |- |align="right" data-sort-value="122000"| {{convert|122000|ha|acre|abbr=values}} |- |align="right" data-sort-value="195600"| {{convert|195600|ha|acre|abbr=values}} |- |align="right" data-sort-value="53700"| {{convert|53700|ha|acre|abbr=values}} |- |align="right" data-sort-value="14100"| {{convert|14100|ha|acre|abbr=values}} |- |align="right" data-sort-value="67500"| {{convert|67500|ha|acre|abbr=values}} |- |align="right" data-sort-value="79500"| {{convert|79500|ha|acre|abbr=values}} |- |<!-- align="right"| -->{{TBA}} |- |<!-- align="right"| -->{{TBA}} |- |}
See:
Please do not edit my sandboxes. Anybody can create their own. --Timeshifter (talk) 15:37, 10 September 2013 (UTC)
See this section higher up:
When I remove rowspan and colspan from the headers the problem is solved. See:
Please do not edit my sandboxes. Anybody can create their own. --Timeshifter (talk) 15:37, 10 September 2013 (UTC)
{| class="wikitable sortable plainrowheaders" |+ Japanese serow conservation areas{{sfn|Ono|2000|p=145}} |- ! scope="col" colspan="2"|Name ! style="border-bottom:none" | <!-- Top half of the "Established" header --> ! style="border-bottom:none" | Size ! style="border-bottom:none" | <!-- Top half of the "Prefectures" header --> |- ! scope="col"|English ! scope="col"|Japanese ! scope="col" style="border-top:none"|Established ! scope="col" style="border-top:none" data-sort-type="number"|ha (acres) ! scope="col" style="border-top:none"|[[Prefectures of Japan|Prefecture]](s)
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)
(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:
--Timeshifter (talk) 09:08, 25 April 2013 (UTC)
(unindent). Here is the same chart, but using rowspan too:
|
{| 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)
This second example (by using rowspan) does not work correctly when there is one or more columns right to the row/colspan group of columns:
|
{| class="wikitable sortable" |- ! rowspan="2" | name ! colspan="2" | Data columns ! rowspan="2" | Another column |- ! data ! more data |- | cats | 273 | 53 | 1 |- | dogs | 65 | 8,492 | 2 |- | mice | 1,649 | 548 | 3 |} |
In Firefox 24.0, the first column "name" runs properly; "data" sorts "more data"; "more data" sorts "Another column"; and "Another column" sorts "data". Sorry but bugzilla:38911 hasn't be fixed very well. –pjoef (talk • contribs) 15:55, 5 October 2013 (UTC)
When I use the Sortable table on the Welsh Wikipedia, the English title "Sortable table" hovers heavily above it. This is unnecessary, even in English imho; certainly unnecessary in every other language. How do I get rid of it please? For example: A list of Welsh Literary Books published since 1996. - Llywelyn2000 (talk) 23:16, 16 October 2013 (UTC)
It would be nice to have some way, for long tables with several columns, to repeat the header, or have it floating when you scroll down, or *something*, without having to disable sortability or end up with all the spare headers bunched together if you sort. Is there any way to do this?
Several basic approaches I can imagine:
1. have a way to basically say "ignore this line when you're sorting, this is row 20 regardless of what goes on around it" or the like
2. have a way to make a table automatically spit out a "header" line every 20 rows (or whatever)
3. use framing or the like to have a "floating" header line that stays visible when you scroll past the header
This is particularly a problem for the "vampire traits" page. It has *huge* tables, mostly consisting of columns with entries like "yes", "fatal", "no", and the like. Tamtrible (talk) 00:52, 11 July 2013 (UTC)
I've been working for more than an hour with edit previews to make the table at Template:Boxer Rebellion sortable, but it's not working! The problem seems to come from the complex table caption, which contains the table title, an image file, and an image caption. Three different things happen depending on what code I use to introduce the table caption:
Here's my table for the third example:
{| class="wikitable sortable" border="1" align="right" style="margin-left: 1em; text-align:right;" |- ! colspan="4" align="center" cellspacing="0" | '''Forces of the [[Eight-Nation Alliance]]<br/> <small>Relief of the [[Beijing Legation Quarter|Legations]]</small>'''<br />[[File:Troops of the Eight nations alliance 1900.jpg|300px]]<br /><small><center>Troops of the Eight-Nation Alliance in 1900.<br />Left to right: Britain, United States, Australia<ref>[http://www.4808.info/html/2008-05/4469p2.html Example of Australian uniform of the period]</ref>, British India,<br /> Germany, France, Austria-Hungary, Italy, Japan</center></small> |- ! align=center | '''Countries''' ! align=center | '''Warships'''<br/> <small>(units)</small> ! align=center | '''Marines'''<br/> <small>(men)</small> ! align=center | '''Army'''<br/> <small>(men)</small> |- |[[Empire of Japan|Japan]] |18 |540 |20,300 |- | [[Russian Empire|Russia]] | 10 | 750 | 12,400 |- | [[British Empire|United Kingdom]] | 8 | 2,020 | 10,000 |- | [[French Third Republic|France]] | 5 | 390 | 3,130 |- | [[United States]] | 2 | 295 | 3,125 |- | [[German Empire|Germany]] | 5 | 600 | 300 |- | [[Austria–Hungary]] | 4 | 296 | |- | [[Kingdom of Italy (1861–1946)|Italy]] | 2 | 80 | |-class="sortbottom" | '''Total''' | 54 | 4,971 | 49,255 |}
I'm not competent enough with tables to figure this out, so I'd be very grateful for your help! Cheers, Madalibi (talk) 12:11, 21 February 2014 (UTC)
See section higher up: #Sorting not working with complex headers. I copied this table from that section so as to focus discussion.
|
{| class="wikitable sortable" |- ! rowspan="2" | name ! colspan="2" | Data columns ! rowspan="2" | Another column |- ! data ! more data |- | cats | 273 | 53 | 1 |- | dogs | 65 | 8,492 | 2 |- | mice | 1,649 | 548 | 3 |} |
I read that there is a patch being reviewed that may fix this. See comment 8 in bugzilla:38911: "Timeshifter, patch for bug 53211 – https://gerrit.wikimedia.org/r/#/c/98250/ – should fix that as well."
So when this table works, that means the patch code has been installed. --Timeshifter (talk) 08:07, 9 December 2013 (UTC)
I use class=sortkey
(in a span). Works good for me. Shouldn't it be in the doc, or is it deprecated? -DePiep (talk) 19:19, 18 April 2014 (UTC)
At List of largest lakes and seas in the Solar System, I specified that the columns were to sort by "number", and set the data-sort-value for individual cells (with and without commas in the values), but I can't get the table to sort numerically. What am I doing wrong? — kwami (talk) 19:24, 24 April 2014 (UTC)
colspan
parameter has been removed, it works for me. -- Michael Bednarek (talk) 03:39, 25 April 2014 (UTC)
Can anyone direct me to an explanation of the Chinese language name sorting defaults used in 'wikitable sortable'? This is in connection with the article List of power stations in China (for example Coal). Thank you. Kleinzach 07:33, 8 May 2014 (UTC)
Can someone please check List of Indian states and territories by highest point.
Am I the only one seeing the first table as an unsortable and purple colored? The second table is working fine for me.
If others are not facing this problem, any idea why I could be having it?
Thanks. Ashinpt (talk) 09:34, 19 June 2014 (UTC)
When I click one of the headers, the year column breaks into individual lines but nothing else happens. I'm on Chrome. Darkwarriorblake / SEXY ACTION TALK PAGE! 20:42, 10 July 2014 (UTC)
rowspan
to construct the table. —EncMstr (talk) 22:36, 11 July 2014 (UTC)Sorting is working for me in Firefox and Internet Explorer (I don't have Chrome) in this revision of the table:
Let us check the easy stuff first. Do the previous posters have problems with complex headers? From Help:Sorting: Section titled: "Tables with complex headers":
Supposedly, people should no longer have a problem with this table below. Sorting is working for me. Is it working for you?
name | Data columns | Another column | |
---|---|---|---|
data | more data | ||
cats | 273 | 53 | 1 |
dogs | 65 | 8,492 | 2 |
mice | 1,649 | 548 | 3 |
If that table sorts for you, then the next step is figuring out what is happening farther down in the table in question. I am just trying to get a base line of what is working for all of us. --Timeshifter (talk) 13:52, 12 July 2014 (UTC)
Which algorithm is used by the Wikimedia software to sort sortable tables? This question seems to be not of interest concerning practical uses, but it determines wether the sort is stable (when I have understood the term "stability" in algorithm theory correctly), and finally, it influences the user experience (a stable sorting algorithm would allow him to easily sort by various criteria simultaneously). — Preceding unsigned comment added by 2003:45:CB20:E622:3D7B:4EA5:BF9B:189E (talk) 19:47, 23 September 2014 (UTC)
I have what I think is a fairly simple sortable table, Table of models with four sortable columns, two number and two date. All work fine in Chrome v37 on both Win7 (64 bit) and WinXP but the date columns don't sort in IE8/XP, IE11/Win7 or Firefox 31. The first column, Date, sorts fine in all systems. I'm thinking about going to data-sort-type="number" and using embedded sort values as a work around. Anyone else have the same problem? Any help would be appreciated? Tom94022 (talk) 21:51, 9 October 2014 (UTC)
data-sort-type="number"
to sort dates, I just put data-sort-value="yymmdd"| Month Year
into each cell and it is working so far. Thanks for supporting the article. Tom94022 (talk) 06:30, 11 October 2014 (UTC)
The help page now says: "Avoid rowspan in body of table". I find this a bit too strong. As we know, these days the rowspan is undone when a reader clicks a sortbutton (the table is turned into single-rows only with repeated cellcontent: all correct).
Indeed, adding rowspan is a complicating, but I don't see why it should be "avoided" (no exception mentioned!).
First of all, adding rowspan can be desirable before any sorting comes in play. It is a basic table feature. Second, using rowspan and sorting correctly, why not? The "avoid" 'advice' (actually to be read as a MOS guideline) does not prove that is causes errors or a wrong reader experience.
I suggest the wording is changed. There could be a warning in there, but not a scare. And to be clear, I am not planning to undo the pages where I applied rowspan in a sortable. -DePiep (talk) 08:34, 17 October 2014 (UTC)
T33775 I'm building the List of mammals of Oregon which currently has sortable tables with a background color, but it does not have the arrows pointing up and down in the column header, like most of the other sortable tables do.
Header with color background example:
Name | Species Authority | Family | State distribution and notes | Red List |
---|---|---|---|---|
Virginia opossum![]() |
Didelphis virginiana (Kerr, 1792) |
Didelphidae | introduced early 1900s; adverse impacts on native bird populations from nest disturbances and egg consumption | ![]() |
Header with arrow but no color example:
Name | Species Authority | Family | State distribution and notes | Red List |
---|---|---|---|---|
Virginia opossum![]() |
Didelphis virginiana (Kerr, 1792) |
Didelphidae | introduced early 1900s; adverse impacts on native bird populations from nest disturbances and egg consumption | ![]() |
Is there a way to have both the arrows and the background color? —Gaff ταλκ 21:29, 25 October 2014 (UTC)
I did not find a solution either. I sometimes use this compromise:
Name | Species Authority | Family | State distribution and notes | Red List |
---|---|---|---|---|
Virginia opossum![]() |
Didelphis virginiana (Kerr, 1792) |
Didelphidae | introduced early 1900s; adverse impacts on native bird populations from nest disturbances and egg consumption | ![]() |
Thank you. Somebody at the Help Desk showed me a solution and I came up with this:
Name | Species Authority | Family | State distribution and notes | Red List |
---|---|---|---|---|
Virginia opossum![]() |
Didelphis virginiana (Kerr, 1792) |
Didelphidae | introduced early 1900s; adverse impacts on native bird populations from nest disturbances and egg consumption | ![]() |
—Gaff ταλκ 01:46, 26 October 2014 (UTC)
Name | Species Authority | Family | State distribution and notes | Red List |
---|---|---|---|---|
Virginia opossum | Didelphis virginiana (Kerr, 1792) |
Didelphidae | introduced early 1900s; etc. | ![]() |
Hello,
I was trying (on the French Wikipedia) to create sortable tables with both "rowspan" and "colspan" attributes. As it wasn't working I tried tables with "rowspan" or "colspan" only. The first ones are working well, but none of the tables with "colspan" do. After some research (including information on this page) I found that "colspan" was still preventing sortable tables to work well. I'd like to know if there has been any improvement regarding this issue lately, and if not why this bug page was closed in Bugzilla while "colspan" is still breaking table sorting.
Encolpe (talk) 08:15, 14 October 2014 (UTC)
Hi! I created a new Bigzilla Report, still unsuccessfully so far ;) Encolpe (talk) 08:02, 2 November 2014 (UTC)
DePiep. You can reword stuff, but not wholesale remove whole sections as you did here. Not without discussion. We already changed the title as you requested. --Timeshifter (talk) 13:04, 10 November 2014 (UTC)
I am performing some technical cleanup. Some issues:
-- Gadget850 talk 13:21, 10 November 2014 (UTC)
Letter | Number |
---|---|
A | 4 |
6 | |
B | 1 |
5 | |
C | 3 |
2 |
In a sortable table like the above one, when you click on any column's header to sort by that column's contents the contents of the cells of the first column will be split and doubled. Is there any way to code such a table that it only splits if you sort on the second column and that if you sort back on the first column after having sorted on the second column the cells that were split in two are merged again to their original state? Tvx1 02:20, 1 March 2015 (UTC)
I have a similar problem as the one inquired above. When I sort that table in my Sandbox, Moszkowski's Op. 3 for instance, appears with Title, Opus number and Year displayed in four lines, not in one, the way it should be. The same happens with every composition containing more than one movement or key. How could I solve this problem and display Title, Opus and Year without doubling ? Krenakarore TK 23:05, 23 March 2015 (UTC)
When you sort this table by year http://en.wikipedia.orghttps://demo.azizisearch.com/lite/wikipedia/page/United_Nations_list_of_Non-Self-Governing_Territories#Change_in_status_by_administrating_state the order is complete nonsense! There isn't any logic to it! WTF? Oh and yet the sorting works perfectly right in the editing preview, just not when it's saved. Still can't sort properly. In 2015... --178.0.100.7 (talk) 11:45, 13 April 2015 (UTC)
Can anyone explain to a markup-challenged individual (me) why numerical list/columns default to sorting by the first digit, rather than by whole numbers? I can't think of many situations in which such a default is useful. Is this, perhaps, an unintended side-effect of alphabetical sorting?
There are quite a few broken tables out there as a result, and I (for one) find the instructions for using data-sort-type="number" difficult to follow, to say the least.
I don't know how difficult to implement this would be, but: it would save a lot of work if the in-built default sorting of digits worked differently to that of alphabetical characters. Grant | Talk 05:24, 1 June 2015 (UTC)
Could someone possibly have a look at what's gone wrong with the tables here (under Target seats)? The final four columns to the right sort fine in preview mode but they refuse to sort properly on the article itself. —Nizolan (talk) 23:13, 11 May 2015 (UTC)
Conservative Party
Rank | Constituency | Region | Winning party 2010 |
Swing required (%) |
Result | Swing to CON (±%) |
---|---|---|---|---|---|---|
1 | Hampstead and Kilburn | London | Labour | 0.10 | Labour hold | -1.0 |
2 | Bolton West | North West England | Labour | 0.10 | Conservative gain | +0.9 |
3 | Solihull | West Midlands | Liberal Democrats | 0.16 | Conservative gain | +11.9 |
4 | Southampton Itchen | South East England | Labour | 0.22 | Conservative gain | +2.8 |
5 | Mid Dorset and North Poole | South West England | Liberal Democrats | 0.29 | Conservative gain | +11.6 |
6 | Wirral South | North West England | Labour | 0.66 | Labour hold | -4.8 |
7 | Derby North | East Midlands | Labour | 0.68 | Conservative gain | +0.8 |
8 | Wells | South West England | Liberal Democrats | 0.72 | Conservative gain | +7.4 |
9 | Dudley North | West Midlands | Labour | 0.84 | Labour hold | -4.7 |
10 | Great Grimsby | Yorkshire and the Humber | Labour | 1.08 | Labour hold | -5.7 |
I removed all the rowspans and colspans. I cleaned the table up further by removing all the sort templates. They were unnecessary. All the columns sort correctly. --Timeshifter (talk) 22:42, 15 May 2015 (UTC)
Is there any way to add filters on row headers to only show some of the rows in a given table. I understand that this is not trivial as it requires to adapt to each data types and to provide a minimal boolean function, but that would be a (very) nice addition to sortable tables. Along the same way it would be nice to allow sorting on multiple columns (A then B, then C). knd (talk) 09:10, 12 June 2015 (UTC)
I am currently working on this table. After reading the advice in this page, my understanding is that it is impossible to have the cells containing numbers sorted first, with blank/NA/- cells following afterwards. Is that correct? AtHomeIn神戸 (talk) 05:35, 23 July 2015 (UTC) Updated link since page has been moved. AtHomeIn神戸 (talk) 02:04, 2 September 2015 (UTC)