Open this example in the interactive library
Live preview
Source code
// 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>
);
}
