Dev Helpers

React / Sorting and arrangement

Natural numeric order

Dev Helpers · October 24, 2025

Natural numeric sorting handles labels such as item 2 and item 10 in a familiar order. Use a collator with an explicit locale where order matters.

Worked example

// components/NaturalNumericOrder.tsx

export default function NaturalNumericOrder({
  entries = ["Beta", "Alpha", "Gamma"],
}: { entries?: string[] } = {}) {
  const collator = new Intl.Collator("en", { numeric: true });
  return (
    <ol>
      {[...entries].sort(collator.compare).map((v, i) => (
        <li key={i}>{v}</li>
      ))}
    </ol>
  );
}

Implementation notes

Numeric comparison still needs a locale and tie policy. Two visually similar labels with different padding can compare as equivalent.

Try it yourself

Include padded numbers and mixed case among the labels.

Open the React example →

Editorial date October 24, 2025 · Published December 6, 2026

Related articles

Percentage meter

A percentage meter needs both a bounded visual fill and a meaningful textual value. Handle a zero denominator before dividing.

Vertical typesetting sample

Vertical typesetting changes the reading direction and available inline space. Treat the sample text as content so it remains selectable and accessible.

Square cover crop

A square image crop gives a card grid consistent geometry. The crop anchor determines whether the most important part of a photo survives.