Sort DOM elements by a configurable property
Sorter class that uses DOM as a source of data and will sort the DOM Elements based on a user defined criteria
Kind: global class
Param | Type | Description |
---|---|---|
baseElementSelector | Element |
Selector to the base element, the childre on which will be sorted |
Example
new PantrySorter(".sort-these").sort((a, b) => a.localeCompare(b), e => e.textContent );
Sort the DOM elements
Kind: instance method of PantrySorter
Param | Type | Description |
---|---|---|
comparator | function |
Comperator function implementation |
compareBy | function |
The property by which the comparison should happen |