Skip to content

Understanding Natural Sorting

What is Natural Sorting?

Natural sorting is a human-friendly way of ordering items that matches how people naturally think about ordering. It's particularly important for equipment where you might have items with numbers in their names.

Traditional vs Natural Sorting

Traditional (ASCII) Sorting

Scanner 1
Scanner 10
Scanner 11
Scanner 2
Scanner 3
Scanner 4

Natural Sorting (What We Use)

Scanner 1
Scanner 2
Scanner 3
Scanner 4
Scanner 10
Scanner 11

Why This Matters

Equipment often has numerical identifiers. For example:

  • Operating Room 1, Operating Room 2, Operating Room 10
  • Ultrasound Machine 1, Ultrasound Machine 2, Ultrasound Machine 10
  • Lab Scanner 1, Lab Scanner 2, Lab Scanner 10

Natural sorting ensures these are displayed in a logical order that matches how humans think about numbers.

How Our Natural Sorting Works

Our system implements several rules to make sorting intuitive:

  1. Case Insensitive

    • "scanner" and "Scanner" are treated the same
    • This prevents items from being split up based on capitalization
  2. Number Recognition

    • Numbers within text are recognized and sorted numerically
    • "Room 2" comes before "Room 10"
  3. Mixed Content Handling

    • Handles combinations of text and numbers intelligently
    • "Scanner 2A" comes before "Scanner 2B"
    • "Scanner 2" comes before "Scanner 2A"

Examples in Practice

Medical Device Inventory

Ultrasound 1
Ultrasound 2
Ultrasound 10
Ultrasound 20
Ultrasound 100

Room Equipment

OR Equipment 1
OR Equipment 2
OR Equipment 10
OR Equipment A1
OR Equipment A2
OR Equipment A10

Serial Numbers

CT-1000
CT-1001
CT-1002
CT-10000

Benefits of Natural Sorting

  1. Reduced Errors

    • Items appear in an order that makes sense
    • Less likely to miss items when scanning a list
  2. Faster Scanning

    • Users can quickly find items in expected positions
    • No need to mentally reorder numbers
  3. Consistent Organization

    • All lists follow the same logical ordering
    • Makes inventory management more intuitive
  4. Better Reporting

    • Reports and exports maintain logical ordering
    • Easier to spot patterns or missing items

Technical Note

Our natural sorting implementation:

  • Ignores case sensitivity
  • Properly handles leading zeros
  • Manages special characters consistently
  • Supports unicode characters
  • Maintains performance even with large datasets

This ensures that whether you're looking at 10 items or 10,000 items, they'll always be ordered in a way that makes sense to human readers.

Released under the AGPL-3.0 License.