function getPriority(a) { if (typeof a === 'symbol') { return 1; } if (a === null) { return 2; } if (a === undefined) { return 3; } if (a !== a) { return 4; } return 0; } const compareValues = (a, b, order) => { if (a !== b) { if (typeof a === 'string' && typeof b === 'string') { return order === 'desc' ? b.localeCompare(a) : a.localeCompare(b); } const aPriority = getPriority(a); const bPriority = getPriority(b); if (aPriority === bPriority && aPriority === 0) { if (a < b) { return order === 'desc' ? 1 : -1; } if (a > b) { return order === 'desc' ? -1 : 1; } } return order === 'desc' ? bPriority - aPriority : aPriority - bPriority; } return 0; }; export { compareValues };