Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hughsk/sort-dom
Sort a DOM node's children
https://github.com/hughsk/sort-dom
Last synced: 8 days ago
JSON representation
Sort a DOM node's children
- Host: GitHub
- URL: https://github.com/hughsk/sort-dom
- Owner: hughsk
- License: mit
- Created: 2014-02-21T05:37:41.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2014-02-21T05:37:46.000Z (over 10 years ago)
- Last Synced: 2024-04-14T13:05:57.734Z (7 months ago)
- Language: JavaScript
- Size: 97.7 KB
- Stars: 2
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# sort-dom [![Flattr this!](https://api.flattr.com/button/flattr-badge-large.png)](https://flattr.com/submit/auto?user_id=hughskennedy&url=http://github.com/hughsk/sort-dom&title=sort-dom&description=hughsk/sort-dom%20on%20GitHub&language=en_GB&tags=flattr,github,javascript&category=software)[![experimental](http://hughsk.github.io/stability-badges/dist/experimental.svg)](http://github.com/hughsk/stability-badges) #
Sort a DOM node's children.
## Usage ##
[![sort-dom](https://nodei.co/npm/sort-dom.png?mini=true)](https://nodei.co/npm/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`.``` javascript
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](http://github.com/hughsk/sort-dom/blob/master/LICENSE.md) for details.