1/** 2 * Ordering for the record grid. 3 * 4 * The grid renders this array row-major (a CSS `grid`, left-to-right then 5 * top-to-bottom), so the array order IS the reading order. 'date-asc' remains 6 * available for a chronological timeline after a reader picks a year in the 7 * volume bars (issue #529). The archive opens with 'date-desc' so fresh work is 8 * visible first. 9 * 10 * Record dates are ISO 'YYYY-MM-DD', so a lexicographic compare is already 11 * chronological. The `|| ''` guards keep a record with a missing date or title 12 * from throwing, sorting it as the earliest/empty key 13 * rather than crashing the whole list. 14 */ 15 16export const RECORD_SORTS = ['date-asc', 'date-desc', 'title-asc']; 17 18const COMPARATORS = { 19 'date-asc': (a, b) => (a.date || '').localeCompare(b.date || ''), 20 'title-asc': (a, b) => (a.title || '').localeCompare(b.title || ''), 21 'date-desc': (a, b) => (b.date || '').localeCompare(a.date || ''), 22}; 23 24/** 25 * Return a new array of records ordered for display. Unknown sort keys fall 26 * back to 'date-desc' (newest-first), the historical default. Pure: the input 27 * array is not mutated. 28 * 29 * @param {Array<{date?: string, title?: string}>} records 30 * @param {string} sortBy - one of RECORD_SORTS; anything else means date-desc 31 * @returns {Array} a sorted copy 32 */ 33export const sortRecords = (records, sortBy) => { 34 const cmp = COMPARATORS[sortBy] || COMPARATORS['date-desc']; 35 return [...records].sort(cmp); 36};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.