Open this example in the interactive library
Source code
type Row = { id: number; name: string; rank: number | null };
const rows: Row[] = [
{ id: 2, name: "Beta", rank: null },
{ id: 1, name: "Alpha", rank: 3 },
];
console.log(rows.map((r) => r.id).toSorted((a, b) => a - b));
Sample output
[ 1, 2 ]
