Hex Value Sorter

Sort a list of hex values by their actual numeric value (compared as BigInt, not as text), ascending or descending, so short values like "9" correctly sort before longer ones like "10" despite having fewer characters. A free online tool from Staaarter, right in your browser.

Runs locallyUpdated 2026-07-26

Overview

Introduction

Sorting a list of hex values by their character content instead of their actual number is a classic trap, "10" looks like it should come after "9" alphabetically, but numerically 0x9 is smaller than 0x10, not larger.

This tool sorts a list of hex values by their real numeric value using exact BigInt comparison, so the order always matches what the numbers actually mean, not just how their digits happen to be arranged as text.

What Is Hex Value Sorter?

The Hex Value Sorter reads a list of hex values, converts each to its exact numeric equivalent, and reorders the list by that value, ascending or descending depending on the toggle you choose.

It never modifies any value itself; the digits of each entry in the output are byte-for-byte identical to how they appeared in the input, just reordered.

How Hex Value Sorter Works

Each value in the input list is parsed and converted to a BigInt, which represents its exact numeric value without any floating-point precision loss, even for very long hex strings.

The list is then sorted by comparing those BigInt values directly (not the original text), and reversed afterward if descending order was requested.

When To Use Hex Value Sorter

Use this whenever you need a list of hex values in genuine numeric order, for example arranging a set of memory addresses, IDs, or magnitude-varying values from smallest to largest.

If you instead want to reorder digits within each individual value (not reorder the list itself), Hex Digit Sorter is the tool for that.

Features

Advantages

  • Compares true numeric value via BigInt, avoiding the classic "10 sorts before 9" lexical-sort trap entirely.
  • Works correctly regardless of differing digit lengths across the list.
  • Handles arbitrarily large hex values without any precision loss.

Limitations

  • Only sorts by numeric value; it has no option to sort by digit count, alphabetical text order, or any other criterion.
  • All values in the list must be valid hex; an invalid entry causes an error naming its position rather than being skipped silently.

Examples

Ascending sort

Input

FF
1A
100, order: ascending

Output

1A
FF
100

By numeric value: 0x1A (26) < 0xFF (255) < 0x100 (256), even though "100" is textually shorter-looking in a different sense than "FF".

Descending sort

Input

FF
1A
100, order: descending

Output

100
FF
1A

The same three values in reverse numeric order, largest first.

Best Practices & Notes

Best Practices

  • Use this instead of a generic text/line sorter whenever the values you're sorting are meant to be interpreted as numbers.
  • If your list mixes values with and without a 0x prefix, don't worry, the prefix is stripped before comparison so it doesn't affect the sort.

Developer Notes

Values are compared with `hexDigitsToBigInt(a) - hexDigitsToBigInt(b)`, converting the sign of that BigInt difference into a `-1/0/1` comparator result (since `Array.prototype.sort` expects a plain number, not a BigInt, from its comparator), then the array is reversed for descending order.

Hex Value Sorter Use Cases

  • Arranging a list of memory addresses or offsets into genuine ascending or descending order
  • Ordering a set of hex-encoded IDs by magnitude rather than by their text representation
  • Quickly finding the minimum or maximum value in a list (it becomes the first or last line)

Common Mistakes

  • Assuming a plain text sort would give the same result; it wouldn't whenever values differ in digit length ("10" vs "9" being the classic example).
  • Forgetting the toggle defaults to ascending; check it before assuming the largest value is first.

Tips

  • After sorting ascending, the first line is always the list's minimum value, and the last line is always its maximum.
  • Combine with Hex Value Padder afterward if you want the sorted, aligned column to also share a fixed digit width.

References

Frequently Asked Questions