Skip to content

feat(pinia-orm): support Intl.Collator for locale aware sorting#2033

Merged
CodeDredd merged 1 commit into
mainfrom
feat/orderby-sort-flags
Jul 20, 2026
Merged

feat(pinia-orm): support Intl.Collator for locale aware sorting#2033
CodeDredd merged 1 commit into
mainfrom
feat/orderby-sort-flags

Conversation

@CodeDredd

Copy link
Copy Markdown
Owner

Feature (#2006)

orderBy() sorted strings by code point, so non-English characters ended up in the wrong place (Š after U instead of between B and T in Lithuanian).

orderBy() on query & repository, useSortBy()/collect().sortBy() and the exported orderBy util now accept an Intl.Collator in addition to the existing SortFlags:

useRepo(Item).orderBy('name', 'asc', new Intl.Collator('lt')).get()
useSortBy(items, 'name', new Intl.Collator('lt'))
  • Collators only compare string values; the existing null/undefined/number ordering is untouched.
  • Each chained orderBy() can carry its own flag/collator (per-criterion flags array internally).
  • A collator also unlocks { numeric: true }, case options etc. for free.
  • Docs updated (orderBy() API page + useSortBy() helper page).

Tests

3 new tests: repository sort with lt collator, util-level collator sort, per-field mixed flags. Full suite green (412 tests).

closes #2006

orderBy() (query & repository), useSortBy and the orderBy util now
accept an Intl.Collator besides the existing sort flags. String values
are then compared with the collator, enabling locale aware ordering
(e.g. Lithuanian A, B, Š, T, U) and options like numeric sorting.
Different flags can be given per order clause.

closes #2006
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 82.35294% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 99.30%. Comparing base (018acee) to head (ee623e8).

Files with missing lines Patch % Lines
packages/pinia-orm/src/support/Utils.ts 75.00% 0 Missing and 2 partials ⚠️
packages/pinia-orm/src/query/Query.ts 75.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2033      +/-   ##
==========================================
- Coverage   99.40%   99.30%   -0.10%     
==========================================
  Files          82       82              
  Lines        3025     3030       +5     
  Branches      533      539       +6     
==========================================
+ Hits         3007     3009       +2     
  Misses         15       15              
- Partials        3        6       +3     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@CodeDredd
CodeDredd merged commit fd64e31 into main Jul 20, 2026
10 of 13 checks passed
@CodeDredd
CodeDredd deleted the feat/orderby-sort-flags branch July 20, 2026 15:06
@github-actions github-actions Bot mentioned this pull request Jul 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

orderBy() does not sort correctly with non-English characters (e.g. "Š")

2 participants