[whatwg] Sortable Tables

Tab Atkins Jr. jackalmage at gmail.com
Thu Dec 27 19:40:17 PST 2012


On Dec 27, 2012 6:04 PM, "Ian Hickson" <ian at 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



More information about the whatwg mailing list