Skip to content

ui: sort names with embedded numbers naturally - #41

Open
fcsonline wants to merge 1 commit into
bjarneo:mainfrom
fcsonline:fix/natural-name-sort
Open

ui: sort names with embedded numbers naturally#41
fcsonline wants to merge 1 commit into
bjarneo:mainfrom
fcsonline:fix/natural-name-sort

Conversation

@fcsonline

Copy link
Copy Markdown
Contributor

Summary

Text cells in the table sorted lexically after lowercasing. Node and pod names with embedded numbers ordered wrong. For example, node-10 sorted before node-2.

This change adds naturalLess and uses it as the fallback comparator in cellLess. 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 test
  • make vet
  • New cases in TestCellLess for node-2 vs node-10, EC2-style node names, and mixed case.
  • New TestNaturalLess covering leading zeros, prefixes, digit-vs-punctuation, and antisymmetry.

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
fcsonline force-pushed the fix/natural-name-sort branch from 4253c6c to f145836 Compare September 10, 2026 14:52
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