Help talk:Sorting

From Wikipedia, the free encyclopedia

Contents

[edit] Possible improvement for Template:Dts

I saw that {{Dts}} was copied from m:Template:Dts. Help:Sorting is pretty cool stuff. But since I'm a lazy programmer and wikieditor, I'm always looking for a way to cut corners. Check out {{User:MrDolomite/Sandbox/Dts}} and let me know what you all think. — MrDolomite | Talk 18:04, 11 January 2007 (UTC)

It's caused a couple problems already, and we have the opportunity to fix them before it gets used everywhere and there's lots of fixin' to do. Check out Template Talk:Dts for more. —Wikibarista 18:04, 21 March 2007 (UTC)

[edit] Sort key

Is it possible (or would it be possible) for cells to have a sort key different from that which is displayed? I want to make List of Liverpool F.C. players sortable, but for it to be useful I really need:

  • To sort the names by surname, firstname
  • To sort the flag icons by nation name
  • To sort the positions in the order of (roughly) GK, Defender, Midfielder, Forward.

--ArtVandelay13 13:19, 11 February 2007 (UTC)

No, sorry, that is not possible right now. The obvious solution to issue #1 is to make the displayed text itself in Last, First format. The obvious solution to issue #2 is to convey the information in words rather than with an image. Christopher Parham (talk) 23:47, 12 February 2007 (UTC)
Perhaps the best solution for sorting by images (e.g national flags) is to have images be sortable by alt text. Pimlottc 01:46, 13 February 2007 (UTC)
Please check out the discussion underway at Template talk:Sortname. You can use {{sortname}} today to solve the first problem, and {{sort}} or {{sortkey}} to solve the other two. Andrwsc 00:24, 5 April 2007 (UTC)

[edit] colspan=2

The script, while ingenious, doesn't work very well with headers spanning over several columns, effectively screwing up List of members of the Riksdag, 2002-2006 by requiring a separate header for the colors (resulting in that column being unnecessarily wide). Solution, anyone? Jobjörn (Talk ° contribs) 21:03, 22 February 2007 (UTC)

[edit] Tables not being sorted

For some reason I'm no longer able to get tables in WP to obey the instruction class="wikitable sortable". Is this a known problem? JavaScript is not disabled on my system.

It must be something to do with my WP Preferences, because the problem disappears when I log out. I don't remember changing anything in the Prefs, however: any suggestions? I've tried bypassing my cache, but that didn't help.

What would I need to do (or have done) to disable the "sortable" property on my computer? -- NigelG (or Ndsg) | Talk 09:41, 13 March 2007 (UTC)

PS What I really meant is: the buttons don't appear at the top of the columns. When I log out they do appear, & the table sorts correctly. -- NigelG (or Ndsg) | Talk 17:54, 13 March 2007 (UTC)
It's OK: I've got to the root of the problem, which was in my monobook.js. Panic over! -- NigelG (or Ndsg) | Talk 18:06, 14 March 2007 (UTC)
I get exactly the same problem. If I'm logged in then "sortable" just seems to be ignored. If I log out or empty my monobook.js then it works. Does anybody have more information on what we need to fix in monobook.js to get sortable tables to work.--MarkS(talk) 07:16, 7 April 2007 (UTC)
Found the problem. I use the Extra Edit Buttons script. This had a function with the name getElementsByClassName which prevented sortable tables from working. I guess, therefore, that the sortable script also has the same function name. I've change extra edit buttons to use a different name. I guess though that other scripts could also include a function with this name so watch out. --MarkS(talk) 21:10, 7 April 2007 (UTC)

[edit] Sortkeys

I started a discussion at Template talk:Sort, since there seem to be a number of unconnected efforts to create sortkeys for sortable wikitables. ~ trialsanderrors 23:21, 2 April 2007 (UTC)

[edit] number sorting

I've read this page and looked at the code in the example table, but I don't quite get what is the best way to get numbers of varying lengths to sort properly (i.e. for 17,000,000 to show up as larger than 900,000). In particular, I would like to fix the attendance numbers at List of sports attendance figures. Thanks for any help. — Reinyday, 00:15, 5 April 2007 (UTC)

Try the {{nts}} template! You would write {{nts|17000000}} to render &&&&&&&&17000000.017,000,000, and the sort keys would work as expected. Andrwsc 00:22, 5 April 2007 (UTC)
  • Excellent. Thanks! — Reinyday, 19:03, 6 April 2007 (UTC)