This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 20526 - This "sorted" attribute seems misleading to me, conveys a different meaning (a state, "sorted")
Summary: This "sorted" attribute seems misleading to me, conveys a different meaning (...
Status: RESOLVED WORKSFORME
Alias: None
Product: WHATWG
Classification: Unclassified
Component: HTML (show other bugs)
Version: unspecified
Hardware: Other other
: P3 normal
Target Milestone: Unsorted
Assignee: Ian 'Hixie' Hickson
QA Contact: contributor
URL: http://www.whatwg.org/specs/web-apps/...
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-12-27 18:16 UTC by contributor
Modified: 2013-01-30 20:37 UTC (History)
4 users (show)

See Also:


Attachments

Description contributor 2012-12-27 18:16:04 UTC
Specification: http://www.whatwg.org/specs/web-apps/current-work/multipage/tabular-data.html
Multipage: http://www.whatwg.org/C#table-sorting-model
Complete: http://www.whatwg.org/c#table-sorting-model

Comment:
This "sorted" attribute seems misleading to me, conveys a different meaning (a
state, "sorted").  Semantically innacurate. It also has two different
propiertes, a sorting type ("reversed") and a sorting order (1, 2...N). IMHO,
that's misguided.

Posted from: 200.61.186.57
User agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:19.0) Gecko/20121217 Firefox/19.0
Comment 1 Pablo Cúbico 2012-12-27 18:30:36 UTC
Sorry, I wrote the previous comment, just wanted to add:

For example: a "sorted" attribute could be useful for conveying state, like a "selected" or "disabled" attribute.

I guess this could be splitted in something like sortorder="reversed" and sortindex, or sortpriority for the >= 1 value.
Comment 2 Ian 'Hixie' Hickson 2012-12-27 21:37:04 UTC
Well, it _is_ a state, in that once the attribute is set, the column is sorted by the user agent.

I don't think splitting the attribute is a good idea since it makes defining the semantics somewhat more complicated (what if you only have the reversed attribute, for instance? When you click, does it change both? In what order? etc).

Assuming it's just one attribute, what would be a better name than "sorted"?

I wanted to call it just "sort", but that conflicts with the method name sort().
Comment 3 Pablo Cúbico 2012-12-27 21:53:22 UTC
- what would be a better name than "sorted"?
Good question! :) 

As you say, if you consider it to be a state, "sorted" could be the way to go to stick with a single attribute. Unless someone comes up with a better choice.

However, digging a little deeper, I was just thinking that I find the "reversed" keyword a little confusing or "non-standardy". I prefer "ASCending" or "DESCending" as a directional property (as in SQL), rather than "reversed" vs. "normal". Defaulting to "ascending" when absent.
Comment 4 Ian 'Hixie' Hickson 2012-12-30 19:10:02 UTC
The reason it's "reversed" and not "ascending"/"descending" is that sometimes "reversed" means "ascending".

Consider this case:

   <table>
    <tr><th sorted="reversed 1">A <th sorted="2">N
    <tr><td>A <td>1
    <tr><td>A <td>2
    <tr><td>A <td>3
   </table>

The result is:

   A N
   A 3
   A 2
   A 1

The primary key is reversed, which flips the sort order of the secondary key, so even though the secondary key is "ascending", the data is still actually descending. You need this because otherwise clicking the A column to flip the sort order would actually leave the rows in the same sort order in both directions.

But if you want to discuss that further please file a separate bug. This bug is about the naming of the "sorted" attribute.

In the absence of a better suggestion for the name, I can't really change it.
Comment 5 Ian 'Hixie' Hickson 2013-01-30 20:37:31 UTC
In the absence of a better name, I am leaving it as "sorted". Please do reopen the bug if you can come up with a better name soon, though.