sort-dom
Sort a DOM node's children.
Usage
sort(parent, comparator)
Where parent
is the element whose children you wish to sort, and comparator
is a comparator function equivalent to what you'd use with
Array.prototype.sort
.
var node = document.getElementById('sortme')
var sort = require('sort-dom')
sort(node, function(ea, eb) {
var a = ea.innerHTML.toUpperCase()
var b = eb.innerHTML.toUpperCase()
return a > b
? +1 : a < b
? -1 : 0
})
License
MIT. See LICENSE.md for details.