Worked example
Before
file10
file2
file1After
file1
file2
file10The numeric portions are compared as 1, 2, and 10 while the labels stay unchanged.
Exactly what this changes
- Natural sorting uses an explicit English collator with numeric comparison enabled. This makes “file2” come before “file10” in ascending order, while an ordinary alphabetic sort may place the character 1 before the character 2.
- Only ordering changes. PlainSift preserves leading zeros, letter case, punctuation, spacing, and every other code point in each original line. It does not rename values or convert digit groups to a standard number format.
- Equal comparisons are stable, so entries that the collator considers equivalent keep their prior relative order. Exact duplicate lines also remain present. Descending changes the comparison direction without reversing text inside a line.
Options and edge cases
- Select ascending for smaller embedded digit values first or descending for larger values first. Mixed text and numbers are compared as complete labels rather than parsed as decimal-only numeric lines.
- Use Sort numbers instead when every valid line should be parsed as a decimal or scientific-notation number and invalid lines should be grouped visibly at the bottom.
Edge case: Leading-zero forms can compare equally under numeric collation; the stable sort then preserves their input order. The original zeros are never removed from the displayed result.