How does it work?
This tool sorts lines of delimited text (like CSV or TSV) based on a specific token (field) within each line. You specify the delimiter that separates the tokens and the index of the token to use for sorting.
The sorting follows these rules:
- Each line is treated as a separate item to sort
- Lines are split into tokens using the specified delimiter
- Only the token at the specified index is used for comparison
- Token indices are 0-based (the first token is at index 0)
- If a line doesn't have a token at the specified index, it's treated as having an empty token
- Case sensitivity can be toggled on or off
- Numeric sorting can be enabled for tokens that contain numbers
Example
Consider this CSV data with name, age, city, and job:
John Doe,42,New York,Engineer
Jane Smith,38,Los Angeles,Designer
Bob Johnson,55,Chicago,Manager
Alice Brown,29,San Francisco,Developer
Charlie Wilson,47,Boston,ArchitectSort by age (token index 1, numeric sorting):
Alice Brown,29,San Francisco,Developer
Jane Smith,38,Los Angeles,Designer
John Doe,42,New York,Engineer
Charlie Wilson,47,Boston,Architect
Bob Johnson,55,Chicago,ManagerSort by city (token index 2):
Charlie Wilson,47,Boston,Architect
Bob Johnson,55,Chicago,Manager
Jane Smith,38,Los Angeles,Designer
John Doe,42,New York,Engineer
Alice Brown,29,San Francisco,DeveloperThis tool is useful for:
- Sorting CSV, TSV, or any delimited data by a specific column
- Organizing data exports from spreadsheets or databases
- Sorting configuration files with structured data
- Arranging log entries by specific fields
- Sorting data with varying field lengths where position-based sorting won't work
Common delimiters
,- Comma (for CSV files)\t- Tab (for TSV files, type "\t" in the delimiter field)|- Pipe (common in data processing);- Semicolon (used in some European CSV formats)- Space (for space-separated values)
Tip:
When working with numeric data (like ages, prices, or quantities), be sure to enable the "Numeric sorting" option to ensure proper numerical order (e.g., 2 comes before 10).
Other tools
See other tools