Skip to main content

sort

The sort command sorts rows in a CSV file based on a specified column.

Syntax​

qsv sort [options] <column> <input_file> [<output_file>]

Description​

The sort command is used to sort rows in a CSV file based on a specified column. This is useful for organizing data and preparing it for analysis.

Options​

  • -r, --reverse: Sort in reverse order
  • --no-headers: When set, the first row will not be interpreted as headers

Examples​

Sort by Column​

Sort rows by the transaction_id column:

qsv sort transaction_id DLD_Transactions_English_500.csv | qsv table

Sort in Reverse Order​

Sort rows by the transaction_id column in reverse order:

qsv sort -r transaction_id DLD_Transactions_English_500.csv | qsv table

Common Use Cases​

  • Organizing data
  • Preparing data for analysis

Tips​

  • Verify the output to ensure the data is correctly sorted
  • Use in combination with other commands for complex data processing

See Also​

  • select - for selecting specific columns
  • apply - for data transformations