when sorting do numbers come before letters

Numbers Before Letters: The ABCs of Sorting

By Brian Hernandez
AD

When dealing with alphanumeric data, a common question arises: when sorting, do numbers come before letters? The answer is a bit more complex than a simple yes or no, as it heavily depends on the sorting rules and their implementation in programming languages or algorithms.

The most common sorting method, which adheres to technical standards like Unicode and ASCII, respetely, is to place numbers before letters. However, it's essential to understand that this is not a universal rule and can differ based on specific requirements or cultural context.

Sorting Rules in Unicode and ASCII

In Unicode and ASCII, characters are assigned specific code points. Numbers are assigned lower code points than letters. This is why when sorted, numbers naturally appear before letters in the sequence.

AD
Free Printable Letters and Numbers Sort for Young Learners
Free Printable Letters and Numbers Sort for Young Learners
Letter & Number Recognition Sorting!
Letter & Number Recognition Sorting!
the crayon box sort worksheet is shown with numbers, letters and numbers
the crayon box sort worksheet is shown with numbers, letters and numbers

For instance, in the range of ASCII values (0-127), digits (48-57) appear before uppercase letters (65-90) and lowercase letters (97-122). This order is respected in most programming languages and algorithms.

Numbers vs Letters in Unicode and ASCII

In the context of Unicode and ASCII, digits (0-9) are considered punctuation, while letters (a-z, A-Z) are considered characters. Due to their lower code point assignment, numbers are treated as 'smaller' than letters during sorting.

The Ultimate Guide to Comparing and Sorting for Preschoolers
The Ultimate Guide to Comparing and Sorting for Preschoolers
Sorting Activity with Cutting and Gluing
Sorting Activity with Cutting and Gluing
Letters vs. Numbers
Letters vs. Numbers

Here's an example of sorting in ASCII: "bcdea123" sorts to "123bcdea", illustrating that numbers come before letters.

Sorting Sensitivity and Case

Sorting sensitivities like case-insensitivity or accent-insensitivity can also affect the order of numbers and letters. In case-insensitive sorting, both 'a' and 'A' would be treated as 'a', meaning numbers would come before all 'a's, regardless of case.

AD

Consider this example: "Bcdea123a" sorts to "123aBcdea" in case-insensitive sorting, while in case-sensitive sorting, it would remain "Bcdea123a" since 'a' and 'A' are distinct.

Free Printable Sorting Activities for Kids - The Activity Mom
Free Printable Sorting Activities for Kids - The Activity Mom
a printable worksheet for sorting and sorting numbers with the words sorting by letter
a printable worksheet for sorting and sorting numbers with the words sorting by letter
Letter Worksheets – Rainbow Preschool Activities
Letter Worksheets – Rainbow Preschool Activities
Sorting Activity
Sorting Activity
Sorting Math Numbers
Sorting Math Numbers
Letter and Number Recycle Bin Sorting Worksheets – Earth Day Theme Worksheets Pack
Letter and Number Recycle Bin Sorting Worksheets – Earth Day Theme Worksheets Pack

Cultural and Programming Language Considerations

While Unicode and ASCII provide a widespread standard, other sorting rules may be used in specific cultural contexts. In some languages, like Thai, Lao, or Khmer, letters are grouped together and sorted before numbers.

Similarly, programming languages or algorithms might implement custom sorting rules. For instance, the Windows operating system by default sorts numbers mixed with letters according to a so-called 'natural sorting' or 'human sorting' method, which places numbers and letters separately.

AD

Natural or Human Sorting

In natural or human sorting, sequences like "file1", "file10", "file2" would remain grouped, rather than the numbers being separated: "file1", "file2", "file10". This is more intuitive for humans, but it's essential to understand that this approach can vary across systems and is not a universal standard.

Sorting Fun: Early Learning Math Activities - Busy Toddler
Sorting Fun: Early Learning Math Activities - Busy Toddler
Letter and Number Sort
Letter and Number Sort
Magnetic Letter Sorting to Teach the Alphabet
Magnetic Letter Sorting to Teach the Alphabet
Preschool Vibes on Instagram: "Here’s how I teach numbers in preschool 🔢 January is when I get extra intentional with number instruction. I teach two numbers a week, moving in order from 1–10, and I introduce a new number every couple of days. I start with a quick explicit lesson using my Meet the Numbers cards. We learn how the number is written using Handwriting Without Tears language (for 2: one big curve + one little line), then we give the number real meaning by seeing it in multiple ways—fingers, a jar of objects, dice/domino, tally marks, and a ten frame. We connect it to our bodies (two eyes, two ears, two hands), do a quick number move (jump two times, blink twice, tap shoulders twice), and finish with a real-world connection (a bird has two wings). It only takes a few minutes, b Number Lessons For Preschool, Teach Numbers Preschool, Teaching Numbers To Kindergarten, Teaching Numbers 1-10 Preschool, Teaching Numbers Preschool 1-20, Teaching Numbers Preschool Activities, Number Circle Time Activities, Teaching Preschool Numbers, Teaching Numbers Preschool
Preschool Vibes on Instagram: "Here’s how I teach numbers in preschool 🔢 January is when I get extra intentional with number instruction. I teach two numbers a week, moving in order from 1–10, and I introduce a new number every couple of days. I start with a quick explicit lesson using my Meet the Numbers cards. We learn how the number is written using Handwriting Without Tears language (for 2: one big curve + one little line), then we give the number real meaning by seeing it in multiple ways—fingers, a jar of objects, dice/domino, tally marks, and a ten frame. We connect it to our bodies (two eyes, two ears, two hands), do a quick number move (jump two times, blink twice, tap shoulders twice), and finish with a real-world connection (a bird has two wings). It only takes a few minutes, b Number Lessons For Preschool, Teach Numbers Preschool, Teaching Numbers To Kindergarten, Teaching Numbers 1-10 Preschool, Teaching Numbers Preschool 1-20, Teaching Numbers Preschool Activities, Number Circle Time Activities, Teaching Preschool Numbers, Teaching Numbers Preschool
Number sorting 1-10
Number sorting 1-10
Sorting Letters by their Physical Characteristics {101 Ways to Teach the Alphabet}
Sorting Letters by their Physical Characteristics {101 Ways to Teach the Alphabet}
a tray with letters and numbers on it that says, abc 123 letter and number sort
a tray with letters and numbers on it that says, abc 123 letter and number sort
Letter Number Sort Worksheets | Concepts of Print Kindergarten Pre-K Preschool
Letter Number Sort Worksheets | Concepts of Print Kindergarten Pre-K Preschool
Fun Printable Number Sorting Activities for Kids (1-10) | Kindergarten Worksheets
Fun Printable Number Sorting Activities for Kids (1-10) | Kindergarten Worksheets
Pre-K to K Letters and Numbers Sorting Activity
Pre-K to K Letters and Numbers Sorting Activity
Number Sorting Cards - This Reading Mama
Number Sorting Cards - This Reading Mama
Learning Numbers and Letters Sorting
Learning Numbers and Letters Sorting
Letter or Number Worksheet
Letter or Number Worksheet
Learn to Sort, Count and Write Worksheet for Kids
Learn to Sort, Count and Write Worksheet for Kids

Here's an example in action: If you Google "sort numbers and letters", you'll find that Google's results sort according to natural/human sorting, with "1" appearing mixed with the 'ones' (numbers) rather than the 'one's' (abbreviation of 'original').

So, while it's a common behavior in computer science to place numbers before letters, this isn't an absolute rule. The order depends on the specific sorting system, its rules, and its implementation. Therefore, understanding and respecting these rules within their respective contexts is crucial for accurate and predictable results.

AD
AD