-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Can i specify the sort rule when sort an table #12605
Copy link
Copy link
Closed
Labels
deprecated:questionQuestions should be redirected to GitHub discussionsQuestions should be redirected to GitHub discussions
Milestone
Description
Question
for example, i want to sort the result of ls command by the filename length.
~> ls
╭───┬─────────────────────┬──────┬─────────┬──────────────╮
│ # │ name │ type │ size │ modified │
├───┼─────────────────────┼──────┼─────────┼──────────────┤
│ 0 │ dump.rdb │ file │ 975 B │ 3 weeks ago │
│ 1 │ redis-stable │ dir │ 4.0 KiB │ 3 months ago │
│ 2 │ redis-stable.tar.gz │ file │ 3.3 MiB │ 3 months ago │
╰───┴─────────────────────┴──────┴─────────┴──────────────╯
i checked the document: sort-by(https://www.nushell.sh/commands/docs/sort-by.html), i think it can accept a closure to sort by any rule. like this:
ls | sort-by {|row| $row.name | length}
Additional context and details
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
deprecated:questionQuestions should be redirected to GitHub discussionsQuestions should be redirected to GitHub discussions