data sort - speced/respec GitHub Wiki

data-sort

Applies to: <ol>, <ul>, <dl>

Sorts the top-level items of a list alphabetically. Useful for dependency sections, IDL member definitions, glossaries, and any list that should stay alphabetically ordered.

Usage

<ul data-sort>
  <li>Banana</li>
  <li>Apple</li>
  <li>Cherry</li>
</ul>
<dl data-sort="descending">
  <dt>Banana</dt><dd>A yellow fruit.</dd>
  <dt>Apple</dt><dd>A red or green fruit.</dd>
  <dt>Cherry</dt><dd>A small red fruit.</dd>
</dl>

Values

Value Sorts
"ascending" A → Z (default when attribute has no value)
"descending" Z → A

Notes

  • Sorting is shallow — only the top-level items are sorted; nested lists are untouched
  • For <dl>, the <dt> is used as the sort key; associated <dd> elements move with their <dt>
  • Sorting is locale-aware (uses JavaScript's Intl.Collator)
⚠️ **GitHub.com Fallback** ⚠️