fix: use natural sort for caseInsensitiveSort to handle numbers#2380
Merged
meteyou merged 1 commit intomainsail-crew:developfrom Jan 11, 2026
Merged
fix: use natural sort for caseInsensitiveSort to handle numbers#2380meteyou merged 1 commit intomainsail-crew:developfrom
meteyou merged 1 commit intomainsail-crew:developfrom
Conversation
…xes correctly Signed-off-by: Stefan Dej <meteyou@gmail.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes the alphabetical sorting issue for items with numeric suffixes (e.g., "Mmu Pre Gate 10" appearing before "Mmu Pre Gate 2") by implementing natural sort in the caseInsensitiveSort utility function.
Key Changes:
- Refactored
caseInsensitiveSortto uselocaleComparewithnumeric: truefor natural number ordering - Enhanced the function with TypeScript generics and variadic parameters for multi-key sorting
- Simplified the
getMiscellaneousSensorsgetter implementation by leveraging the improved helper
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/plugins/helpers.ts |
Enhanced caseInsensitiveSort with TypeScript generics, natural sort via localeCompare, and multi-key support using rest parameters |
src/store/printer/getters.ts |
Replaced verbose multi-level sorting logic with a single call to the improved caseInsensitiveSort helper |
dw-0
approved these changes
Jan 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR fixes the sorting of items with numeric suffixes (e.g., "Mmu Pre Gate 0", "Mmu Pre Gate 1", ..., "Mmu Pre Gate 10") by implementing natural sort in
caseInsensitiveSort.Previously, items were sorted alphabetically, causing "Mmu Pre Gate 10" to appear before "Mmu Pre Gate 2" because string comparison treats "10" < "2" (comparing character by character).
Whats in this PR:
caseInsensitiveSortto uselocaleComparewithnumeric: trueoptiongetMiscellaneousSensorsgetter to use the improved helper functionBefore:
After:
Related Tickets & Documents
Mobile & Desktop Screenshots/Recordings
n/a
[optional] Are there any post-deployment tasks we need to perform?
n/a