Kefiw

Archived noindex page. Kefiw's public focus is Property decision help.

Archived page

This older Kefiw page is kept for reference, marked noindex, and removed from the primary sitemap. The current Kefiw experience is focused on property decisions: cost, quotes, damage, buying, selling, owning, and packets.

Go to Property

Sort Lines Pitfalls: Natural Sort, Case, and Locale

When the sort looks wrong, it is almost always one of three causes.

Three pitfalls cause 90% of "why is this sorted weirdly" complaints — know them, fix them fast.

Every surprising sort result comes from one of three sources: string-vs-number sort, case-sensitivity, or locale. Diagnose which, and the fix is one toggle away.

Quick answer

Three pitfalls cause 90% of "why is this sorted weirdly" complaints — know them, fix them fast.

What you are trying to do
When the sort looks wrong, it is almost always one of three causes.
Best next step
Sort Lines
Limit to remember
Treat this as a practical aid for the task, not a replacement for professional judgment.

Key points

  • Numbers as strings: "file10" sorts before "file2" because "1" < "2" character-by-character. Switch to natural sort.
  • Case: "Zebra" sorts before "apple" in ASCII because uppercase Z (90) < lowercase a (97). Use case-insensitive sort.
  • Locale: German "ö" sorts with "o" in some locales, with "z" in others. Set locale explicitly if it matters.
  • Leading whitespace: a space-prefixed line jumps to the top because space (32) < A (65). Trim first.
  • Hidden characters: BOM, zero-width space, non-breaking space all sort unexpectedly. Normalise before sorting.

Examples

  • File list surprise
    "img1.png, img2.png, img10.png" → alpha sort → "img1.png, img10.png, img2.png". Natural sort gives the expected "1, 2, 10" order.
  • Case disaster
    Paste "apple, Banana, Cherry, date" — default ASCII sort gives "Banana, Cherry, apple, date" (all caps first). Case-insensitive fixes it.
  • Whitespace gremlin
    One line has a leading space. Sort puts it at the top "mysteriously". Trim the whole list first.

When to use which tool

Related

Frequently asked questions

What is natural sort? Definition

Sort that treats runs of digits as numbers. "file2" comes before "file10" because 2 < 10, regardless of string position.

Does locale sort matter for English-only text?

Rarely — ASCII-only text sorts the same in most locales. It matters once you have accented characters, German ß, or non-Latin scripts.

How should I use this guide with a Kefiw tool? How-to

Use the guide as the plan and the linked Kefiw tool as the check. Read the steps first, try the move manually, then use the tool to compare outputs, catch edge cases, and decide whether the result actually fits your task.

What mistake do tool guides help avoid? Troubleshooting

Tool guides help avoid using a utility mechanically without understanding what you are trying to accomplish. Most word, writing, and text utilities are fast, but speed can hide context mistakes. Know whether you are solving a puzzle, cleaning copy, drafting a line, or checking a rule.

Can a tool guide help me learn the skill? How-to

A tool guide can help you learn if you pause before accepting the output and ask why it worked. Compare your first guess with the tool result, look for the rule or pattern, and repeat that review. Passive copying solves one task; active review builds the skill.