1// Shared alphabetical sorting for model pickers and dropdowns. 2 3function _sortText(value) { 4 return String(value || '').split('/').pop().trim() || String(value || ''); 5} 6 7function _compareText(a, b) { 8 return _sortText(a).localeCompare(_sortText(b), undefined, { 9 numeric: true, 10 sensitivity: 'base', 11 }) || String(a || '').localeCompare(String(b || ''), undefined, { 12 numeric: true, 13 sensitivity: 'base', 14 }); 15} 16 17function _arrayOrEmpty(models) { 18 return Array.isArray(models) ? models : []; 19} 20 21export function sortModelIds(models) { 22 return _arrayOrEmpty(models).slice().sort(_compareText); 23} 24 25export function compareModelObjects(a, b) { 26 const aLabel = a && (a.display || a.displayName || a.name || a.mid || a.id || a.model); 27 const bLabel = b && (b.display || b.displayName || b.name || b.mid || b.id || b.model); 28 return _compareText(aLabel, bLabel); 29} 30 31export function sortModelObjects(models) { 32 return _arrayOrEmpty(models).slice().sort(compareModelObjects); 33}
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.