firestore-snapshot-utils
Version:
[](https://github.com/ericvera/firestore-snapshot-utils/blob/master/LICENSE) [ • 388 B
JavaScript
export const ascCompare = (getValue) => (a, b) => {
const av = getValue(a);
const bv = getValue(b);
if (typeof av === 'number' && typeof bv === 'number') {
return av - bv;
}
else if (typeof av === 'string' && typeof bv === 'string') {
return av.localeCompare(bv);
}
throw new Error('Trying to compare values that are not string or number');
};