Skip to content

Module: lib/dom/sortElements

Sorts the direct child elements of a container by their data-sort attribute. Elements with:

  • data-sort < 0 → Excluded from sorting, moved last, and get tabindex="-1".
  • data-sort ≥ 0 → Sorted in ascending order.
  • no data-sort → Appended before or after the sorted items depending on sortOrder.
Version
1.0.0
Author
Frank Kudermann - alphanull
License
MIT
Source
sortElements.js, line 12

Methods

static sortElements(container, sortOrderopt)

Sorts the direct child elements of a container by their data-sort attribute.

Parameters:
Name Type Attributes Description
container HTMLElement

The container whose children should be sorted.

sortOrder 'sorted-last' | '' optional

Determines whether sorted items come after ('sorted-last') or before the unsorted ones.

Source
sortElements.js, line 20