W3C home > Mailing lists > Public > whatwg@whatwg.org > June 2010

[whatwg] Sort child nodes of a DOM node.

From: Biju <bijumaillist@gmail.com>
Date: Fri, 4 Jun 2010 02:49:40 -0400
Message-ID: <AANLkTimNLX_rDFNIu85EOxmaguL7E2E0pOU0CMqjvIfN@mail.gmail.com>
There are many cases where we want to sort child nodes of a DOM node.
Many times it is TR nodes of a TBODY

Right now user writes javascript code to achive that.
Dont you think it is better if there was built DOM method for each node.
Additionally the method will have a sort function parameter to compare elements
the same way as in JavaScript Array.sort(compare_func)

function compare_func(a,b){
 if(isHeaderRow(a))  return -1;
 if(isHeaderRow(b))  return 1;
 if(a.textContent == b.textContent) return 0;
 if(a.textContent < b.textContent) return -1;
 return 1;

Use cases:-
Example 1: column sorting in yahoo mail

Example 2: you can sort this listing by clicking the column headers

Example 2: there are bug report in mozilla asking sorting in XUL grids
Received on Thursday, 3 June 2010 23:49:40 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:59:24 UTC