@snipsonian/core
Version:
Core/base reusable javascript code snippets
21 lines (20 loc) • 534 B
JavaScript
export function stringComparerAscending(a, b) {
const x = a || '';
const y = b || '';
return anyComparerAscending(x, y);
}
export function stringComparerAscendingIgnoreCase(a, b) {
const x = a ? a.toLowerCase() : '';
const y = b ? b.toLowerCase() : '';
return anyComparerAscending(x, y);
}
export function anyComparerAscending(x, y) {
return x < y
? -1
: x > y
? 1
: 0;
}
export function anyComparerDescending(x, y) {
return (anyComparerAscending(x, y) * -1);
}