Page MenuHomePhabricator

Force a sortable wikitable to automatically sort by one column upon rendering
Closed, DeclinedPublic

Description

As an editor, I would like a way to force a wikitable to sort itself by a specific column upon rendering. This is not currently possible, cf:

It is not possible to make a table appear sorted by a certain column without the user clicking on it. By default, the rows of a table always appear in the same order as in the wikitext. If you want a table to appear sorted by a certain column, you must sort the wikitext itself in that order - https://meta.wikimedia.org/wiki/Help:Sorting#Default_order

Two good example use-cases:

  1. For wikitables where multiple fields change regularly/annually. These updates often necessitate resorting the wikitext itself, which can be very time-consuming (even if following the workaround described at https://meta.wikimedia.org/wiki/Help:Sorting#Sorting_the_wikitext_of_a_table ).
  2. For wikitables where the raw wikitext in a column is already sorted in ascending order, then a user who clicks on a heading will see no affect the first time. E.g. https://en.wikipedia.org/wiki/List_of_teams_and_cyclists_in_the_2015_Giro_d'Italia#By_starting_number

This feature request was recently mentioned here, but I've seen it requested many times before, e.g.

Event Timeline

Quiddity raised the priority of this task from to Needs Triage.
Quiddity updated the task description. (Show Details)
Quiddity added a subscriber: Quiddity.
Krinkle added a subscriber: Krinkle.

Sorting of initial render should be done server-side, not client-side.

This cannot be done in a performant way on the client and only defers the underlying problem, which is an editing or rendering problem. I suggest exploring solutions to this problem through additional features in the Parser, or via an extension, or by generating the table with a Lua module.

Either way, in a way that will output the desired HTML when the page is rendered, no matter how it is consumed or displayed. Regardless of client-side javascript (which is for interaction only).

Much thanks for the explanation, and especially for the suggested alternative solutions. :-)

Someone more technical than I am, will have to write up any further feature-requests (or code) based on those suggestions.