Page MenuHomePhabricator

Provide way to sort a table column in descending order on first click
Closed, ResolvedPublicFeature

Description

Feature summary

Make an option for a sortable table column to use descending order on the first click, e.g. with class="sortreverse" in the column header or something like data-sort-type="number; descending".

Use case(s)

You often have to click twice to get the sort order nearly everybody probably wants, especially for numbers where larger often means better or more interesting like medals or population.
Some users may not even realize they can click again to reverse the order.

Benefits
Most users would get their wanted sort order with a single click.

Event Timeline

neriah changed the task status from Open to In Progress.May 29 2026, 8:48 AM
neriah claimed this task.
neriah triaged this task as Medium priority.

Change #1295403 had a related patch set uploaded (by Neriah; author: Neriah):

[mediawiki/core@master] tablesorter: Allow descending sort on first click

https://gerrit.wikimedia.org/r/1295403

We should document the new feature on https://www.mediawiki.org/wiki/Help:Sortable_tables (noting in which version it was added). This will likely be useful in articles, so I think it's worth a User-notice. There are probably other documentation pages on other wikis that could be updated to document it.

Change #1295403 merged by jenkins-bot:

[mediawiki/core@master] jquery.tablesorter: Add option for descending sort on first click

https://gerrit.wikimedia.org/r/1295403

Hello @neriah,
For tech news, is this wording okay?

"Wikimedia projects have improved sortable table columns: now, clicking a column header once sorts it in descending order. Previously, users had to click twice to achieve this, which was not widely known. This change makes sorting tables faster and more intuitive."

"Wikimedia projects have improved sortable table columns: now, clicking a column header once sorts it in descending order. Previously, users had to click twice to achieve this, which was not widely known. This change makes sorting tables faster and more intuitive."

That's not accurate. A column is only sorted in descending order on first click if it has data-sort-order="desc" specified. See https://www.mediawiki.org/wiki/Help:Sortable_tables#Forcing_the_initial_sort_direction.

"Wikimedia projects have improved sortable table columns: now, clicking a column header once sorts it in descending order. Previously, users had to click twice to achieve this, which was not widely known. This change makes sorting tables faster and more intuitive."

That's not accurate. A column is only sorted in descending order on first click if it has data-sort-order="desc" specified. See https://www.mediawiki.org/wiki/Help:Sortable_tables#Forcing_the_initial_sort_direction.

Thanks for the clarification.

I now the information as:

Wikitables can now be sorted in descending order on the first click by adding data-sort-order="desc" to the header cell. Previously, by default, clicking a column header for the first time sorts it in ascending order. This addition to a Wikitable gives it more control and flexibility, while the default behavior for subsequent clicks remains unchanged.

@UOzurumba: I'd still link to the docs. Please allow curious people to learn more about the entire "sorting tables" area if they are interested.
I don't know if the currently proposed text links, as https://meta.wikimedia.org/wiki/Tech/News/Next is empty, so I do not know where the draft is even located.

@UOzurumba: I'd still link to the docs. Please allow curious people to learn more about the entire "sorting tables" area if they are interested.
I don't know if the currently proposed text links, as https://meta.wikimedia.org/wiki/Tech/News/Next is empty, so I do not know where the draft is even located.

Yes, I linked it the Tech News. Sorry I did not add it immediately.