Sort Rows Column Lexicographic
Stably sort CSV data records by a selected column using deterministic UTF-16 code-unit ordering, with an explicit direction and header flag.
Description
Lexicographic sorting compares text spelling rather than numeric magnitude.
Lexicographic sorting compares text spelling rather than numeric magnitude. A deterministic code-unit order makes results independent of locale collation.1
Stably sort CSV data records by a selected column using deterministic UTF-16 code-unit ordering, with an explicit direction and header flag.
When to use Sort Rows Column Lexicographic
Use this for the following task: Stably sort CSV data records by a selected column using deterministic UTF-16 code-unit ordering, with an explicit direction and header flag.
Prepare the CSV text, decoded cells or byte values requested below. Choose delimiter and header flags explicitly when those fields are present.
How to use Sort Rows Column Lexicographic and understand its results
- Prepare the CSV text, decoded cells or byte values requested below. Choose delimiter and header flags explicitly when those fields are present.
- Enter csv, delimiter, hasHeader, column, direction using the field table, then run the tool.
- Read csv. Interpret flags, units, ordering and placeholder values using the rules below.
- Review any reported issue or failed check, correct the supplied values when appropriate, and verify the result in its intended context.
| Input field | Meaning | Value type and bounds | Requirement |
|---|---|---|---|
| csv | CSV text | string; maximum text length 100000 | Required |
| delimiter | Delimiter | string; choose ",", ";", "\t" | Required |
| hasHeader | Has header | boolean | Required |
| column | Column | integer; minimum 0 | Required |
| direction | Direction | string; choose "ascending", "descending" | Required |
Parse rectangular records and preserve the explicit header. Validate the selected zero-based column, sort ascending/descending and re-encode records.2
Parse delimiters only outside quoted fields and decode doubled quotes. A quoted line break stays inside its cell; malformed quoting is returned as an input error.
The shared writer doubles interior quotes and quotes cells when needed for delimiters or line breaks, including a single empty-field record. It normally emits LF record endings without a terminal newline; any tool-specific quote-all behavior is stated above.
order by selected cell using UTF-16 lexical comparison; ties keep original index This summarizes the declared operation. Units, indexing, inclusivity and exceptional cases are explained in the surrounding text.
| Output field | Meaning | Value type |
|---|---|---|
| csv | CSV text | string |
{
"input": {
"csv": "name,id\nGrace,1\nAda,2\nAda,3",
"delimiter": ",",
"hasHeader": true,
"column": 0,
"direction": "ascending"
},
"output": {
"csv": "name,id\nAda,2\nAda,3\nGrace,1"
}
} Limitations and assumptions
Case and whitespace affect order. Numeric-looking strings remain text, so 10 can sort before 2.
Where CSV is parsed, the shared parser accepts comma, semicolon or tab separators, doubled quotes and quoted line breaks, with CR/LF/CRLF record endings. Blank records remain records. CSV inputs are bounded to 100000 UTF-16 units and 10000 fields. Malformed requests produce input errors. A successfully evaluated request can still contain false flags, empty result lists or a result outside the supplied threshold; those outcomes have the meanings stated above.
Alternative or Complementary methods
Choose Numeric Sort EU Decimal-Aware for this operation: Stably sort rectangular CSV rows by exact numbers using comma decimals and optional dot groups of three, preserving original cell spelling and an explicit header. For a complementary task, use Filter Rows Column Equals Value for this operation: Keep CSV data records whose selected zero-based column exactly equals a supplied decoded string, preserving an explicit header and original record order.
Further background: Format and language reference: Sort Rows Column Lexicographic.
References
-
Format and language reference: Sort Rows Column Lexicographic — RFC Editor
-
Sort Rows Column Lexicographic — tool.io
Similar or alternative tools
- Numeric Sort EU Decimal-Aware
Stably sort rectangular CSV rows by exact numbers using comma decimals and optional dot groups of three, preserving original cell spelling and an explicit header.
- Filter Rows Column Equals Value
Keep CSV data records whose selected zero-based column exactly equals a supplied decoded string, preserving an explicit header and original record order.