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.
Often used alongside Hex Digit Sorter, Hex Value Shifter and Hex Value Padder.
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
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.