W3cubDocs

/Nushell

dfr sort-by for lazyframe

sorts a lazy dataframe based on expression(s).

Signature

> dfr sort-by {flags} ...rest

Flags

  • --reverse, -r {list<bool>}: Reverse sorting. Default is false
  • --nulls-last, -n: nulls are shown last in the dataframe
  • --maintain-order, -m: Maintains order during sort

Parameters

  • ...rest: sort expression for the dataframe

Input/output types:

input output
any any

Examples

Sort dataframe by one column

> [[ab]; [62] [14] [41]] |dfr into-df|dfr sort-bya
╭───┬───┬───╮
# │ a │ b │
├───┼───┼───┤
014
141
262
╰───┴───┴───╯

Sort column using two columns

> [[ab]; [62] [11] [14] [24]] |dfr into-df|dfr sort-by [ab] -r [falsetrue]
╭───┬───┬───╮
# │ a │ b │
├───┼───┼───┤
014
111
224
362
╰───┴───┴───╯

Tips: Dataframe commands were not shipped in the official binaries by default, you have to build it with --features=dataframe flag

Copyright © 2019–2023 The Nushell Project DevelopersLicensed under the MIT License.
https://www.nushell.sh/commands/docs/dfr_sort-by.html