Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use the "sortable" and "sorted" attributes in tables?

I recently saw in the W3Schools html tags reference two attributes I don't quite understand. The first is the <table sortable="sortable"> attribute, and the second is <th sorted="sorted"> attribute.

According to W3Schools, the sortable attribute description is:

Specifies that the table should be sortable

And the description for the sorted attribute is:

Defines the sort direction of a column

And the values the sorted attribute accept are:

reversed
number
reversed number
number reversed

I tried to follow the W3C documentation here about how to use those attributes but it doesn't works for me.

I would be very thankful for an answer. Thank you.

like image 661
Michael Haddad Avatar asked Mar 13 '14 10:03

Michael Haddad


2 Answers

In 2016, the table sorting model (including "sortable" and "sorted" attributes) was completely removed from HTML5.1 draft, due to lack of implementations.

Reference: https://github.com/w3c/html/issues/56

like image 131
X. Liu Avatar answered Sep 21 '22 12:09

X. Liu


The W3C document your are referring to is a draft for HTML 5.1, which is scheduled for publication in 2016 and not implemented in any browser today AFAIK (hey, HTML 5 is not yet fully implemented and targets feature freeze in june 2014).

Now, if you need sortable table, there are plenty javascript-based libraries out there that can do that.

like image 20
Pierre Rust Avatar answered Sep 20 '22 12:09

Pierre Rust