sort-dom

0.0.0 • Public • Published

sort-dom Flattr this!experimental

Sort a DOM node's children.

Usage

sort-dom

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.

Package Sidebar

Install

npm i sort-dom

Weekly Downloads

1

Version

0.0.0

License

MIT

Last publish

Collaborators

  • hughsk