Page MenuHomePhabricator

Enable numeric sort for category members
Closed, DuplicatePublic

Description

Category members are currently sorted in alphabetical order. A magic word such as {{NUMERICSORT}} should be introduced to make the sorting sensitive to numbers in sort keys.

For example. a page that contains

[[Category:My category|100]]

i.e. with a sort key of "100" should not be displayed after a page with a sort key of "1" and before "2", but in the proper numeric order, i.e. after any number up to and including "99".

Event Timeline

Dvorapa created this task.Apr 29 2016, 9:41 AM
Danny_B changed the task status from Open to Stalled.Apr 29 2016, 10:18 AM
Danny_B added subscribers: DannyH, matmarex.

There is already some request for numerical sorting (@DannyH : Can you perhaps close this as a dupe in favour of that one? Thx) as well as for per-category collation (@matmarex : I can't find it ATM, could you, pls? Thx)

For the time being: If you need numerical sort, simply pad lower numbers with zeros and optionally with leading space. Cf. eg. https://cs.wikinews.org/wiki/Kategorie:%E2%8C%82
Got an example of category where you need to achieve this goal? (Feel free to ping me on IRC or use [[Special:EmailUser]], so I can navigate/help you)

Blahma renamed this task from Add sort-by-number Magic Word for cats to Enable numeric sort for category members.Apr 29 2016, 10:21 AM
Blahma changed the task status from Stalled to Open.
Blahma updated the task description. (Show Details)
Blahma changed the task status from Open to Stalled.

Technical note: due to its nature it would have to be behavior switch (eg. __NUMSORT__) and not template-like syntax (as mentioned {{NUMERICSORT}}) since it does not add any content to the page.

Removing unrelated projects (please see their descriptions).

Dvorapa added a comment.EditedApr 29 2016, 11:39 AM

@Danny_B in almost every category like "World Championship in athletics YYYY" ("Mistrovství světa v atletice YYYY" categories on cswiki e.g.) and another sport events categories (tennis, voleyball, football, ...). But this is just a small amount of those which should be sorted numerically. Generally years, money amounts (catastrophes), numbers itself, subway lines in larger cities (10 or more subway lines) is just a small amount I found on cswiki today.

@Danny_B Your example looks like it sorts, but not show the headings (2008, 2009). It could be used meanwhile.

@Danny_B Your example looks like it sorts, but not show the headings (2008, 2009). It could be used meanwhile.

Sure it does ;-)

It won't show such headings, since only first character is always shown as the heading.

And actually, in fact it does not make a sense to have sections for single page only.

Define character you want to use as the heading. In categories with numerical only items, I suggest space (as shown in category I linked), in categories with mixed content, I suggest # or №.
So eg. in "Mistrovství světa v atletice 1983" type [[Kategorie:Mistrovství světa v atletice|#1983]] or [[Kategorie:Mistrovství světa v atletice|№1983]]. For pages in categories with numerical only items use [[Kategorie:<pagename>| <numerical-sortkey>]] (mind the space after the pipe).

Dvorapa added a comment.EditedApr 29 2016, 8:50 PM

@matej_suchanek Is this duplicate of T8948 you suggested? If yes, could you, please, close this in favour of that one?

Yeah, I think this is the same as T8948. That would allow choosing either numeric sorting (1 < 2 < 100) or alphabetic sorting ('1' < '100' < '2') for the whole wikis.

If you wanted to be able to decide this on a per-category basis, that would be T30397, which is a much more complicated change to implement (and would require T8948 first).

However, keep in mind that it is comfortably solvable even now by using proper sortkeys as I've described in my posts above.

Dvorapa added a comment.EditedApr 30 2016, 6:44 PM

@Danny_B Sort yes, but group them under better number headings is still not possible.
@matmarex This task was about a magic word to achieve this type of sorting and grouping. I don't know which task is more appropriate, but I believe in your opinion..

@Danny_B Sort yes, but group them under better number headings is still not possible.

An example of how do you expect it work?