k9s icon indicating copy to clipboard operation
k9s copied to clipboard

feat: change sort col using two fixed keys

Open mlosicki opened this issue 4 years ago • 4 comments

My attempt at this feature request: #1000

Description

Change the sort col using two fixed keys, < and >. q changes the sort order. The behaviour is now similar to top

Demo

asciicast (The player doesn't show the key inputs sadly)

Implementation details

  • Used the q key instead of r because it is already used in some places (e.g. node drain). I assumed you do not want to change the default keybindings even though I am personally in favour of refactoring with r
  • I believe the sort implementation could benefit from a refactor. Currently, the values are sorted on the displayed string value. I took the inspiration from age to fix sorting on capacity, but it isn't ideal. It can lead to issues like this too: #885. The original value or a specific compare function should be kept on the level of the Fields or even Row.
  • Not a Go dev, sorry upfront for non-idiomatic code

Closes #1000

mlosicki avatar Sep 14 '21 13:09 mlosicki

This is a great improvement! Here's to hoping it can get merged.

chauncey-garrett avatar Mar 02 '23 19:03 chauncey-garrett

What's the status of this? Any reason it couldn't be merged? In my case I'd love to order by assigned memory limit (not the percentage) which is not possible atm.

olee avatar Jun 13 '24 13:06 olee

Rebased with small fixes here: https://github.com/derailed/k9s/pull/2739

ventsislav-georgiev avatar Jun 15 '24 13:06 ventsislav-georgiev

@derailed This PR dates back to 2021 and k9s now supports asc/desc column sorting, the feature is largely covered. Due to current sorting limitations, it might still be worth revisiting this approach in the future.

uozalp avatar Sep 16 '25 08:09 uozalp