sort-dom

Sort a DOM node's children

sort-dom

Sort a DOM node's children.

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(eaeb) {
  var a = ea.innerHTML.toUpperCase()
  var b = eb.innerHTML.toUpperCase()
 
  return a > b
    ? +1 : a < b
    ? -1 : 0
})

MIT. See LICENSE.md for details.