Last modified: 2011-05-02 20:08:36 UTC

Wikimedia Bugzilla is closed!

Wikimedia has migrated from Bugzilla to Phabricator. Bug reports should be created and updated in Wikimedia Phabricator instead. Please create an account in Phabricator and add your Bugzilla email address to it.
Wikimedia Bugzilla is read-only. If you try to edit or create any bug report in Bugzilla you will be shown an intentional error message.
In order to access the Phabricator task corresponding to a Bugzilla report, just remove "static-" from its URL.
You could still run searches in Bugzilla or access your list of votes but bug reports will obviously not be up-to-date in Bugzilla.
Bug 8288 - Sortable tables don't properly sort lists of names
Sortable tables don't properly sort lists of names
Product: MediaWiki
Classification: Unclassified
Parser (Other open bugs)
All Mac OS X 10.4
: Low enhancement (vote)
: ---
Assigned To: Nobody - You can work on this!
Depends on:
  Show dependency treegraph
Reported: 2006-12-17 08:00 UTC by GabrielF
Modified: 2011-05-02 20:08 UTC (History)
2 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Description GabrielF 2006-12-17 08:00:16 UTC
Great work on the sortable tables javascript!
When the javascript is applied to tables with a column that is a list of names
(e.g. a table of US Senators with a column for the name, state, year elected,
etc.) the script will sort by first name rather than last name, which is
generally the wrong behavior. I would love to see a solution where a user could
define a parameter for a particular column which would tell MediaWiki to sort
that column lexicographically starting with the first letter of the last word in
each cell (the last name). Perhaps this could be achieved by adding an html
comment such as <!--LNAME--> to the first cell in the column.

This is my first bug report so I apologize if its formatted incorrectly. :)
Comment 1 Leon Weber 2006-12-17 08:10:54 UTC
AFAIK, Brion is gonna remove sortable tables.
Comment 2 Aryeh Gregor (not reading bugmail, please e-mail directly) 2006-12-17 19:21:56 UTC
Currently the implementation of sortable tables is very unobtrusive HTML-wise
(just a class), which makes it trivial to implement.  Allowing some kinds of
comments, which are currently stripped by the parser, is a nontrivial task, and
possibly a dangerous one since IE can (by design!) be persuaded to execute
arbitrary HTML inside them.  Probably more sensible would be to uniquely ID all
the rows and have some kind of one-line <script> tag for each that would give
its sort key, but again, that would require Parser changes and could be dangerous.

The only easy and non-dangerous thing I could think of would be to abuse the
class attribute, but that's pretty hacky.  Not as hacky as inexpertly matching a
sort key to the background color and putting it at the beginning of the cell,
though . . .

(In reply to comment #1)
> AFAIK, Brion is gonna remove sortable tables.

I'm pretty sure he wasn't serious.
Comment 3 Jwillbur 2007-02-23 01:08:19 UTC
Incidently, GabrielF's suggestion to sort by the first letter of the last word in
each cell (the last name) does not take into account two (or more) word names.
For example, "John Van Dyke" would be sorted by "Dyke", while it should sort by
"Van Dyke". Having the user explicitly give a sort key for each cell would work
Comment 4 Purodha Blissenbach 2009-08-07 21:47:44 UTC
Here are ideas how this could be accomplished:

1. One could add a column to the table with a class that inhibits its
rendering, and needs a link to the column it is providing a sort key
for. Imho that is too complcated because of the link, and will display
the sort key column in CSS-unaware browsers, and requires editors to add
another columns with proper CSS class for each cell.

2. Add an attibute to <td>s such as
 <td sortkey="van Dam, Joseph P. Anthony">
for cells needing one. It is ignored by html browsers, but the sorting
(java)script could use them, and only resort to the cell content, if
there is no sortkey attribute for a cell. This makes sorting slower, but
since tables tend not to be excessively huge, that should be acceptable.

3. For sorting page titles, we could possibly utilize either of
 {{#DEFAULTSORT:page title}} or {{#DISPLAYTITLE:page title}}
, provided, we add tables for them to the data base, and create
these parser functions, which is pretty trivial with the appropriate
data base fields.
Comment 5 DieBuche 2011-05-02 20:08:36 UTC
Use data-sort-value="van Dam"

Note You need to log in before you can comment on or make changes to this bug.