ui: sort names with embedded numbers naturally - #41
Open
fcsonline wants to merge 1 commit into
Open
Conversation
The fallback comparator in cellLess compared cells lexically after lowercasing. Names with embedded numbers sorted wrong: "node-10" came before "node-2" because "1" < "2" as bytes. Add naturalLess. It splits both strings into digit runs and text runs. Digit runs compare by numeric value. Text runs compare case-insensitively. Equal values fall back to byte order so the ordering stays strict. Numeric and duration cells keep their existing handling.
fcsonline
force-pushed
the
fix/natural-name-sort
branch
from
September 10, 2026 14:52
4253c6c to
f145836
Compare
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.
Summary
Text cells in the table sorted lexically after lowercasing. Node and pod names with embedded numbers ordered wrong. For example,
node-10sorted beforenode-2.This change adds
naturalLessand uses it as the fallback comparator incellLess. It splits each string into digit runs and text runs. Digit runs compare by numeric value. Text runs compare case-insensitively. When two strings are equal under those rules, byte order breaks the tie so the sort stays a strict weak ordering.Duration cells (
5d,2m59s) and numeric-prefixed cells (245m,512Mi,1/1) keep their existing handling.Test plan
make testmake vetTestCellLessfornode-2vsnode-10, EC2-style node names, and mixed case.TestNaturalLesscovering leading zeros, prefixes, digit-vs-punctuation, and antisymmetry.