Skip to content

new: sortable primitive for Solid 2.0 - #1003

Open
davedbase wants to merge 5 commits into
solidjs-community:nextfrom
davedbase:v2/sortable
Open

new: sortable primitive for Solid 2.0#1003
davedbase wants to merge 5 commits into
solidjs-community:nextfrom
davedbase:v2/sortable

Conversation

@davedbase

@davedbase davedbase commented Aug 2, 2026

Copy link
Copy Markdown
Member
  • Adds @solid-primitives/sortable, a new stage-0 package combining ideas from VueUse's useSorted (reactive sort with an in-place dirty mode) and d3-array's comparator utilities (ascending/descending, multi-key composition), built on Solid 2.0 fundamentals rather than a bespoke diffing engine:
    • ascending / descending / by / combine / reverse — comparator building blocks; null/undefined/NaN always sort to the end regardless of direction
    • makeSorted / createSorted — non-reactive and reactive sort (reactive comparator + dirty in-place option); the default path delegates to @solid-primitives/signal-builders's existing sort() instead of re-implementing it
    • sortedIndex / sortedIndexBy / insertSorted — binary search and O(log n) sorted insertion
    • createSortedIndex — per-item reactive rank tracking built on mapArray (the same primitive behind <For>), so an item's index only updates when that item's position actually changes
    • createSortedProjection — a store-shaped sorted view via createProjection(fn, seed, { key }), giving keyed-reconcile granularity with no custom tracking code
  • Adds 4 Storybook stories covering diverse usage: granular rank tracking, multi-column sort (combine/reverse), a lightweight drag-and-drop reorder list (createSortedProjection), and a live sorted feed (insertSorted)
  • Fixes a stale deno.jsonc catalog (still pinned solid-js/@solidjs/web to beta.26, missed in the earlier beta.29 bump) and regenerates deno.lock, and adds packages/sortable/deno.jsonc for JSR
  • .changeset/sortable-initial.md — major bump, initial release

Summary by CodeRabbit

  • New Features

    • Added the @solid-primitives/sortable package for reactive and non-reactive list sorting.
    • Added ascending, descending, multi-criteria, and custom comparator utilities.
    • Added binary-search insertion helpers and sorted index tracking.
    • Added keyed sorted projections that preserve item identity during updates.
    • Added interactive examples for rankings, drag reordering, multi-column sorting, and live feeds.
  • Documentation

    • Added comprehensive API documentation, examples, licensing, and release notes.
  • Tests

    • Added coverage for sorting, reactivity, insertion, projections, SSR, and comparator behavior.

@davedbase davedbase added this to the Solid 2.0 Migration milestone Aug 2, 2026
@davedbase davedbase added the enhancement New feature or request label Aug 2, 2026
@changeset-bot

changeset-bot Bot commented Aug 2, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 125ef0e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@solid-primitives/sortable Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai

coderabbitai Bot commented Aug 2, 2026

Copy link
Copy Markdown

Review Change Stack

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: e11ea82d-be28-41ba-ba31-ed4b613665d2

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The pull request adds the initial @solid-primitives/sortable package. It includes comparator utilities, sorting and search helpers, reactive rank tracking, keyed sorted projections, documentation, package metadata, examples, and tests.

Changes

Sortable package

Layer / File(s) Summary
Package foundation
.changeset/sortable-initial.md, deno.jsonc, packages/sortable/LICENSE, packages/sortable/README.md, packages/sortable/deno.jsonc, packages/sortable/package.json, packages/sortable/tsconfig.json
Adds package metadata, publishing configuration, documentation, licensing, TypeScript configuration, and the initial release changeset. Updates the Solid catalog versions.
Comparator and search contracts
packages/sortable/src/comparators.ts, packages/sortable/src/search.ts, packages/sortable/src/index.ts, packages/sortable/test/comparators.test.ts, packages/sortable/test/search.test.ts
Adds nullish-safe comparators, comparator composition, binary-search helpers, immutable sorted insertion, public exports, and focused tests.
Reactive sorting and projections
packages/sortable/src/sort.ts, packages/sortable/src/index-of.ts, packages/sortable/src/projection.ts, packages/sortable/test/sort.test.ts, packages/sortable/test/index-of.test.ts, packages/sortable/test/projection.test.ts, packages/sortable/test/server.test.ts
Adds reactive sorting with optional dirty in-place updates, per-item reactive indices, keyed sorted projections, and browser-independent coverage.
Interactive sortable examples
packages/sortable/dev/index.tsx, packages/sortable/stories/sortable.stories.tsx
Adds a leaderboard demo and stories for granular rank tracking, multi-column sorting, drag reordering, and live sorted insertion.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant SourceList
  participant createSortedProjection
  participant createProjection
  participant StoreProjection
  participant ReactiveConsumer
  SourceList->>createSortedProjection: provide list and comparator
  createSortedProjection->>createProjection: pass sorted items and key
  createProjection->>StoreProjection: reconcile keyed sorted items
  StoreProjection->>ReactiveConsumer: expose sorted store view
Loading

Suggested labels: solid-2.0, Primitive Proposal

Suggested reviewers: atk

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 70.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the new sortable primitive package for Solid 2.0, which is the main change in the pull request.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/sortable/deno.jsonc`:
- Around line 7-14: Add CHANGELOG.md to the publish.include list in
packages/sortable/deno.jsonc and the files list in
packages/sortable/package.json so the README changelog link remains valid in
both registries; retain the existing link in packages/sortable/README.md because
it will then reference a published file.

In `@packages/sortable/src/comparators.ts`:
- Line 57: Update the reverse comparator’s docstring to prominently document
that argument swapping reverses missing-value placement, causing null,
undefined, or NaN values to sort first with missing-aware comparators. Advise
using descending or a comparator that explicitly handles missing values when
missing values must remain last; leave the reverse implementation unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 218a6219-adcb-4fe8-b29d-7fa9926df284

📥 Commits

Reviewing files that changed from the base of the PR and between fbda35f and 17d61ce.

⛔ Files ignored due to path filters (2)
  • deno.lock is excluded by !**/*.lock
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (21)
  • .changeset/sortable-initial.md
  • deno.jsonc
  • packages/sortable/LICENSE
  • packages/sortable/README.md
  • packages/sortable/deno.jsonc
  • packages/sortable/dev/index.tsx
  • packages/sortable/package.json
  • packages/sortable/src/comparators.ts
  • packages/sortable/src/index-of.ts
  • packages/sortable/src/index.ts
  • packages/sortable/src/projection.ts
  • packages/sortable/src/search.ts
  • packages/sortable/src/sort.ts
  • packages/sortable/stories/sortable.stories.tsx
  • packages/sortable/test/comparators.test.ts
  • packages/sortable/test/index-of.test.ts
  • packages/sortable/test/projection.test.ts
  • packages/sortable/test/search.test.ts
  • packages/sortable/test/server.test.ts
  • packages/sortable/test/sort.test.ts
  • packages/sortable/tsconfig.json

Comment thread packages/sortable/deno.jsonc
Comment thread packages/sortable/src/comparators.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant