Re: [whatwg] Sortable Tables

On Dec 27, 2012 6:04 PM, "Ian Hickson" <ian@hixie.ch> wrote:
> > 2. What values should the sort property allow. One idea is that it takes
> > a JS function similar to what JavaScript's sort function takes. If you
> > leave it out then it just does alphanumeric sort.
>
> I was going to have a comparator function, but I couldn't see a sane way
> to make it work in the face of hostile functions that mutate the DOM, so
> I dropped it. You can do custom sort orders by giving a key in the <data>
> element's value="" attribute, though.

In JS, the comparator passed to sort() can potentially mutate the array
that's being sorted, or delete it entirely. JS engines cope somehow. It's
silly to not support a custom comparator here, since any problems you can
possibly come up with are already present in the existing Array#sort
function.

~TJ

Received on Friday, 28 December 2012 03:40:44 UTC