0.7.4 gives the Ambient pack weather. A page names one feed URL on its own site, and the pack sets data-weather from it, uses its sunrise and sunset for dawn and dusk, and never shows a stale observation. Helpers for producing the feed from Open-Meteo are included. Ambient p…
Client-side list/table sorting upscale on any container — native ul/ol/table or VB collections. Two API shapes (clickable column headers OR external select/button); composes with data-paged.
Overview
The data-sortable attribute upscales any list-shaped container with client-side sorting. Same upscale model as data-paged: pure attribute, no custom element, auto-attaches via the shared init registry. Two API shapes share one engine — clickable <th> headers for tables, external controls (<select> or <button>) for other containers.
Two shapes
Table mode
Each <th data-sort="key"> gets its content wrapped in a native <button data-sort-button>; activating it (click, Enter or Space) cycles the column through asc → desc → none → asc. Row sort-value comes from the matching <td> via (in order): data-sort-value (or its alias data-value), <time datetime> when type is date, otherwise textContent.
Items declare data-sort-{key}=value attributes; an external control declares data-sort-target=selector and supplies the active key. A <select>'s value (or a <button>'s data-sort-byattribute) chooses the key. Leading - on the value flips direction.
The target is looked up when the control is used, so a control may come before its container in the page or be rendered first (the container loaded later, lazily or by a template). A <select>'s initial value is applied as soon as its container appears.
HTML
12345678910
<selectdata-sort-target="#projects"><optionvalue="name">Name (A-Z)</option><optionvalue="-name">Name (Z-A)</option><optionvalue="-priority">Priority (high to low)</option><optionvalue="due">Due date (soonest)</option></select><ulid="projects"data-sortable><lidata-sort-name="Bonsai"data-sort-priority="2"data-sort-due="2026-08-12">...</li></ul>
On external controls: CSS selector for the target container.
data-sort-by
—
On a <button> control: the key to apply on click.
data-sort-{key}
—
On list children: per-key sort value.
data-sort-value
—
Per-cell override; takes precedence over textContent. Same name as <data-table>. data-value is accepted as an alias.
data-label-sorted
Sorted: {sort}. {count} items
List mode: the announcement after a control sorts. {sort} is the control's text (the selected option, or the button's name); {count} the locale-formatted item count. On the container or any ancestor.
Events
The container emits sort:change after each reorder. Use it for analytics, scroll-restoration, or driving a sibling component.
text — Intl.Collator in the container's language (its closest [lang]) with sensitivity: "base" and numeric: true. Case-insensitive; "item 10" sorts after "item 2"; Swedish "ö" sorts after "z" in a lang="sv" list.
number — reads formatted text: grouping separators, currency symbols, units and spaces are ignored ("1,234", "$5", "12 %", "1.234,5", "(4)" as −4). When both , and . appear the last one is the decimal separator; a lone , followed by exactly three digits is grouping. Non-numeric values sort to the end. For anything ambiguous put the raw number in data-sort-value / data-sort-{key}.
date — Date.parse. Use ISO 8601 (YYYY-MM-DD) or <time datetime> for unambiguous parsing.
Empty / nullish values always sort to the end regardless of direction — "no value" is treated as "no opinion, put it last."
Accessibility
Follows the APG sortable table: each <th> keeps its columnheader role and carries the reflected aria-sort (ascending / descending / none), so the column's cells keep their header.
The control is a native <button type="button" data-sort-button> inside the header, named by the header text. Focus, Enter and Space come from the platform; the header cell itself is not focusable.
The ⇅ / ↑ / ↓ glyph is drawn by the native table CSS from aria-sort, with empty alt text, so it is never announced twice. It is the same glyph set <data-table> uses.
External controls use native <select> / <button>. Button controls get aria-pressed="true" while their sort is the active one.
A list has no aria-sort to read, so after a control sorts a list, a polite announcement says what happened ("Sorted: Newest first. 24 items", localisable with data-label-sorted). Table sorts are not announced: the header's aria-sort already says it.
Compose with data-paged
Drop both attributes on the same container. Sorting reorders children; the data-paged engine's MutationObserver sees the reorder and re-paginates from page 1, so the user always lands on the first page of the newly sorted list.
<data-table> ships its own column-level data-sort alongside data-weight, data-rollup, data-heatmap, etc. If you're already using <data-table> for typed cells / weighted rollups / heatmaps, use its built-in sort. Reach for data-sortable when: