Skip to content

fix: alphanumeric sort fix and perf improvement#6310

Merged
KevinVandy merged 1 commit into
betafrom
sort-alphanumeric-improvements
Jun 10, 2026
Merged

fix: alphanumeric sort fix and perf improvement#6310
KevinVandy merged 1 commit into
betafrom
sort-alphanumeric-improvements

Conversation

@KevinVandy

@KevinVandy KevinVandy commented Jun 10, 2026

Copy link
Copy Markdown
Member

🎯 Changes

✅ Checklist

  • I have followed the steps in the Contributing guide.
  • I have tested this code locally with pnpm test:pr.

Summary by CodeRabbit

Release Notes

  • Bug Fixes

    • Fixed auto-sort function selection for mixed data types; text sorting no longer overrides earlier matches.
    • Improved alphanumeric sorting accuracy for columns containing mixed text and numbers.
  • Tests

    • Added comprehensive test coverage for sort function auto-detection and alphanumeric comparison edge cases.

@coderabbitai

coderabbitai Bot commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c284a399-0d4c-4078-b8bb-66bdfdd9b600

📥 Commits

Reviewing files that changed from the base of the PR and between ab4208b and 6ba86a1.

📒 Files selected for processing (5)
  • packages/table-core/src/features/row-sorting/rowSortingFeature.utils.ts
  • packages/table-core/src/fns/sortFns.ts
  • packages/table-core/tests/unit/features/row-sorting/rowSortingFeature.utils.test.ts
  • packages/table-core/tests/unit/fns/sortFns.test.ts
  • perf.md

📝 Walkthrough

Walkthrough

This PR refactors alphanumeric string comparison to handle chunk boundaries explicitly and fixes sort function auto-selection to use early returns instead of post-loop resolution. Changes include updated comparator logic, selection precedence in auto-detection, comprehensive test coverage for both changes, and performance documentation updates.

Changes

Sorting Feature Improvements

Layer / File(s) Summary
Alphanumeric comparator chunk filtering
packages/table-core/src/fns/sortFns.ts, packages/table-core/tests/unit/fns/sortFns.test.ts
compareAlphanumeric stops filtering empty boundary chunks and instead iterates while skipping them, classifies chunks by parsing numeric vs string content via isNaN, and changes exhaustion tie-breaking to count non-empty remaining chunks. Boundary case tests and regression tests validate the comparator against an embedded reference implementation.
Auto-sort function selection via early returns
packages/table-core/src/features/row-sorting/rowSortingFeature.utils.ts, packages/table-core/tests/unit/features/row-sorting/rowSortingFeature.utils.test.ts
column_getAutoSortFn replaces post-loop accumulator logic with early returns during value sampling: immediately returns datetime sort for Date values, alphanumeric sort for mixed text-and-number strings, text sort for plain strings, and basic sort as fallback. Tests verify precedence for each type and fallback when alphanumeric registration is unavailable.
Performance catalog documentation
perf.md
Progress counters updated, finding #52 (compareAlphanumeric) marked done with implementation details and benchmark notes, new finding #61 (column_getAutoSortFn selection fix) added documenting the selection precedence and test coverage, and priority table extended.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Poem

🐰 A sorting refactor hops into view,
Early returns replace loops, fresh and new,
Alphanumeric chunks dance without spill,
Boundary boundaries bend to our will,
Tests hop along, comprehensive and true!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% 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 accurately reflects the main changes: a fix to the alphanumeric sort comparator logic and a performance improvement by removing unnecessary filtering in chunk processing.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch sort-alphanumeric-improvements

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 and usage tips.

@nx-cloud

nx-cloud Bot commented Jun 10, 2026

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit 6ba86a1

Command Status Duration Result
nx affected --targets=test:eslint,test:sherif,t... ✅ Succeeded 2m 50s View ↗
nx run-many --targets=build --exclude=examples/** ✅ Succeeded 27s View ↗

☁️ Nx Cloud last updated this comment at 2026-06-10 13:26:35 UTC

@pkg-pr-new

pkg-pr-new Bot commented Jun 10, 2026

Copy link
Copy Markdown
More templates

@tanstack/angular-table

npm i https://pkg.pr.new/TanStack/table/@tanstack/angular-table@6310

@tanstack/angular-table-devtools

npm i https://pkg.pr.new/TanStack/table/@tanstack/angular-table-devtools@6310

@tanstack/lit-table

npm i https://pkg.pr.new/TanStack/table/@tanstack/lit-table@6310

@tanstack/match-sorter-utils

npm i https://pkg.pr.new/TanStack/table/@tanstack/match-sorter-utils@6310

@tanstack/preact-table

npm i https://pkg.pr.new/TanStack/table/@tanstack/preact-table@6310

@tanstack/preact-table-devtools

npm i https://pkg.pr.new/TanStack/table/@tanstack/preact-table-devtools@6310

@tanstack/react-table

npm i https://pkg.pr.new/TanStack/table/@tanstack/react-table@6310

@tanstack/react-table-devtools

npm i https://pkg.pr.new/TanStack/table/@tanstack/react-table-devtools@6310

@tanstack/solid-table

npm i https://pkg.pr.new/TanStack/table/@tanstack/solid-table@6310

@tanstack/solid-table-devtools

npm i https://pkg.pr.new/TanStack/table/@tanstack/solid-table-devtools@6310

@tanstack/svelte-table

npm i https://pkg.pr.new/TanStack/table/@tanstack/svelte-table@6310

@tanstack/table-core

npm i https://pkg.pr.new/TanStack/table/@tanstack/table-core@6310

@tanstack/table-devtools

npm i https://pkg.pr.new/TanStack/table/@tanstack/table-devtools@6310

@tanstack/vue-table

npm i https://pkg.pr.new/TanStack/table/@tanstack/vue-table@6310

@tanstack/vue-table-devtools

npm i https://pkg.pr.new/TanStack/table/@tanstack/vue-table-devtools@6310

commit: 6ba86a1

@KevinVandy KevinVandy merged commit 98abac5 into beta Jun 10, 2026
8 checks passed
@KevinVandy KevinVandy deleted the sort-alphanumeric-improvements branch June 10, 2026 13:47
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.

1 participant