Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | 1x 1x 1x 1x 7x 7x 5x 5x 7x 7x 1x 1x 3x 3x 1x 1x 1x 1x 1x 1x | export type TitledItem = { id: string; title: string } /** Primary: title (name). Tie-break: id. */ export function compareByTitleAsc(a: TitledItem, b: TitledItem): number { const byTitle = a.title.localeCompare(b.title, undefined, { sensitivity: "base" }) if (byTitle !== 0) { return byTitle } return a.id.localeCompare(b.id, undefined, { numeric: true }) } export function sortByTitleAsc<T extends TitledItem>(items: readonly T[]): T[] { return [...items].sort(compareByTitleAsc) } export function sortStoriesByTitle< T extends TitledItem & { id: string }, >(stories: T[]): T[] { return sortByTitleAsc(stories) } |