Guide
How line sorting works
By Logappradeep · ServiceNow developer
Sorting a list makes it easier to scan, compare, and maintain. Sorted lists of imports, dependencies, translation keys, or allowlist entries produce smaller diffs in code review because new items land in a predictable place, and duplicates end up next to each other where they are easy to spot. This tool sorts lines alphabetically in either direction, by length, or into a random order, and shows the result as you change options.
Locale-aware comparison
Lines are compared with the browser's locale-aware collation rather than raw character codes, so the order feels natural to people:
- Case is ignored by default.
apple,Banana, andcherrysort in that order. A plain code-based sort would putBananafirst, because all uppercase letters come before lowercase in ASCII. Turn on Case sensitive to separate variants, with uppercase placed first (A,a,B,b). - Accented letters sort with their base letter, so
écolesits nearecologyrather than afterz. - Punctuation and symbols generally sort before letters and digits.
Natural number order
Purely alphabetical sorting compares digits one character at a time, which gives 1, 10, 100, 2, 20. That is technically correct but rarely what you want for file names, version numbers, or numbered items. Natural number order, enabled by default, compares runs of digits by their numeric value instead:
img1.png
img2.png
img10.png
Turn it off when you need strict character-by-character order, for example to match the output of a tool that sorts lexically.
Length sorting and shuffling
- Shortest first and Longest first order lines by character count, with alphabetical order breaking ties. This is handy for finding outliers, such as an unusually long log line or a suspiciously short entry in a list of IDs.
- Shuffle puts lines in a random order using the browser's cryptographically secure random generator and an unbiased Fisher–Yates shuffle. Click it again for a new order. It is useful for randomizing quiz questions, picking a running order, or sampling test data fairly.
Things to expect
- Leading spaces count. An indented line usually sorts before unindented ones, which can scramble an outline.
- Blank lines move to the top in A to Z order. Run Remove Empty Lines first for a clean result.
- Duplicates are kept. Sorting groups them together, and Remove Duplicates can reduce them to one each.
- Whole lines move as units. If one logical item spans several lines, such as a multi-line address, sorting will separate its parts.
Typical uses include alphabetizing names and glossary terms, ordering .gitignore and CODEOWNERS entries, and normalizing two lists before comparing them in a diff tool. Sorting happens in your browser, so your lists stay private.