Text to sort

Sort Criteria (in order of priority)

Level 1

Sorted text

How does it work?

This tool sorts lines of text hierarchically based on multiple criteria. It's like sorting a spreadsheet by multiple columns, where each criterion is applied in order of priority.

The sorting follows these rules:

  • Each line is treated as a separate item to sort
  • Lines are split into tokens using the specified delimiter for each criterion
  • Criteria are applied in order (Level 1 first, then Level 2 for ties, etc.)
  • Each criterion can be configured with its own delimiter, token index, and sort options
  • Numeric sorting can be enabled for numeric tokens
  • Each level can be sorted in ascending or descending order

Example

Consider this CSV data with last name, first name, age, city, and job:

Smith,John,42,New York,Engineer
Johnson,Bob,55,Chicago,Manager
Brown,Alice,29,San Francisco,Developer
Wilson,Charlie,47,Boston,Architect
Smith,Jane,38,Los Angeles,Designer

Sort by last name (Level 1), then by age numerically (Level 2):

Brown,Alice,29,San Francisco,Developer
Johnson,Bob,55,Chicago,Manager
Smith,Jane,38,Los Angeles,Designer
Smith,John,42,New York,Engineer
Wilson,Charlie,47,Boston,Architect

Sort by job (Level 1), then by city (Level 2):

Wilson,Charlie,47,Boston,Architect
Smith,Jane,38,Los Angeles,Designer
Brown,Alice,29,San Francisco,Developer
Smith,John,42,New York,Engineer
Johnson,Bob,55,Chicago,Manager

This tool is useful for:

  • Sorting complex data with multiple levels of organization
  • Creating custom sort orders for CSV or delimited data
  • Organizing data by primary, secondary, and tertiary criteria
  • Simulating database-like sorting with multiple columns
  • Preparing data for analysis or presentation with specific ordering requirements

Tips for Hierarchical Sorting

  • Order matters: The criteria are applied in the order listed (Level 1, then Level 2, etc.)
  • Delimiters: Each level can have its own delimiter (comma, tab, space, etc.)
  • Numeric sorting: Enable this for columns containing numbers to ensure proper numerical order
  • Descending order: Check this box to reverse the sort order for a specific level
  • Multiple levels: Add as many levels as needed for complex sorting requirements

Note:

For best results, ensure your data is consistently formatted with the same delimiters throughout. If a line doesn't have a token at the specified index for a criterion, it will be treated as having an empty value for that criterion.

Related Tools

All Tools

See all available tools