Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alphabetic sorting of namespaces containing UUID's incorrect #3108

Open
diskis opened this issue Feb 12, 2025 · 1 comment
Open

Alphabetic sorting of namespaces containing UUID's incorrect #3108

diskis opened this issue Feb 12, 2025 · 1 comment

Comments

@diskis
Copy link

diskis commented Feb 12, 2025




Describe the bug
Alphabetic sorting of namespaces containing UUID's incorrect

To Reproduce
Create a few namespaces of format project-{$uuid}

kubectl create ns project-1da0e1fe-7853-4521-94ef-f28176793f75
kubectl create ns project-01f59712-ba51-4998-b756-e47498d23666

Expected behavior
Alphabetic sorting expected. Above two namespaces will sort correctly with kubectl, but in k9s namespace view will be in wrong order. Other namespaces order just fine, only issues with namespaces that contain uuid's

Screenshots

Image

Versions (please complete the following information):

  • OS: Fedora 41
  • K9s: 0.32.7 (via brew)
  • K8s: multiple
@thorbenbelow
Copy link
Contributor

thorbenbelow commented Feb 14, 2025

Hey, just took a look at it:

  • kubectl without --sort-by: There is no enforced order when listing resources. The order may appear arbitrary depending on how the API server returns results.
  • kubectl --sort-by=<field>: When specifying a field (e.g., --sort-by=.metadata.name), kubectl sorts lexicographically. Ref: sorter.go#L181
  • k9s ordering: k9s applies natural sorting, which ensures that "pod2" comes before "pod10" instead of after it (as it would in lexicographic order). Ref: helpers.go#L142

So the issue is more with any numbers in the name. I guess in the end, this is more about preference—whether you want lexicographic or natural sorting.

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

No branches or pull requests

2 participants