Text Tools

Sorting Text Alphabetically and Numerically Explained

Learn how alphabetical and numerical sorting differ, including why '10' can sort before '2' in plain text order.

Brekzy Team Published September 8, 2026

On this page
  1. Alphabetical (Lexicographic) Sorting
  2. Why “10” Can Sort Before “2”
  3. Case Sensitivity in Alphabetical Sorting
  4. Common Mistakes
  5. Use the Text Sorter

Sorting a list of text alphabetically seems straightforward, until numbers are involved, at which point alphabetical (lexicographic) order and numerical order can disagree in a way that surprises a lot of people the first time they see it.

Alphabetical (Lexicographic) Sorting

Standard alphabetical sorting compares text character by character, the same way words are ordered in a dictionary.

Why “10” Can Sort Before “2”

Sorting the list [“10”, “2”, “1”] alphabetically (as text) gives: 1, 10, 2

Sorting the same list numerically gives: 1, 2, 10

Alphabetical sorting compares the first character first, “1” comes before “2” regardless of what follows it, so “10” sorts before “2” simply because its first digit is smaller. Numerical sorting instead compares the actual numeric value, giving the more intuitive order.

Case Sensitivity in Alphabetical Sorting

Depending on the sorting method, uppercase and lowercase letters can sort differently, some methods treat “Apple” and “apple” as equivalent for ordering purposes, while others sort all uppercase letters before all lowercase ones (or vice versa) based on their underlying character codes.

Common Mistakes

  • Using alphabetical sort on numbers stored as text. This produces the “10 before 2” surprise described above; numeric sorting is needed for numbers to sort in their actual numeric order.
  • Not accounting for case sensitivity. Depending on the tool, a case-sensitive sort can place all-uppercase entries in a different position than expected relative to lowercase ones.
  • Assuming a sorted list is a deduplicated list. Sorting only reorders text; removing duplicates is a separate operation entirely.

Use the Text Sorter

The Text Sorter sorts text alphabetically or numerically instantly, with options for order and case sensitivity.

Try it yourself

Text Sorter

Try our Text Sorter →

Frequently Asked Questions

Why does “10” sort before “2” in alphabetical order?

Because alphabetical sorting compares the first character first; “1” is a smaller character than “2”, so anything starting with “1” sorts earlier, regardless of what digits follow.

How do I sort numbers in their correct numeric order?

Use numeric sorting specifically, rather than alphabetical (text-based) sorting, so values are compared by their actual numeric value instead of character by character.

Does sorting take capitalization into account?

It depends on the sorting method; some treat uppercase and lowercase as equivalent, while others sort based on underlying character codes, which can place all-uppercase entries differently than expected.

Does sorting a list remove duplicate entries?

No, sorting only reorders the list; removing duplicates requires a separate step.

Can I sort a list in reverse order?

Yes, most sorting tools support both ascending and descending order.

Explore More

Find the right tool, or keep reading Brekzy's other guides.