Text to sort

(0-based index, where 0 is the first character)

Sorted text

How does it work?

This tool sorts lines of text based on a specific portion (subselection) of each line. You specify the starting position and optionally an ending position, and the tool sorts the lines based on the characters in that range.

The sorting follows these rules:

  • Each line is treated as a separate item to sort
  • Only the specified portion of each line is used for comparison
  • Character positions are 0-based (the first character is at position 0)
  • If a line is shorter than the start position, it's treated as having an empty subselection
  • If no end position is specified, the subselection extends to the end of the line
  • Case sensitivity can be toggled on or off

Example

Consider this data with name, age, city, and job separated by pipes (|):

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|Architect

Sort by age (positions 5-7): Start position = 5, End position = 7

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

Sort by city (positions 8+): Start position = 8, No end position

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

This tool is useful for:

  • Sorting tabular data by a specific column
  • Organizing CSV or delimited data by a particular field
  • Sorting log files by timestamp or other specific parts
  • Arranging code by specific identifiers or patterns
  • Sorting lists where the sort key is in a consistent position

Tip:

For data with varying field lengths (like CSV files), it's often better to use the "Sort tokens" tool instead, which can split lines by a delimiter and sort by a specific field number.

Other tools

See other tools