const selfSorter = (it: any) => it /** 升序排序 */ export const ascendingSort = (itemProp: (obj: T) => number = selfSorter) => ( (a: T, b: T) => itemProp(a) - itemProp(b) ) /** 字符串升序排序 */ export const ascendingStringSort = (itemProp: (obj: T) => string = selfSorter) => ( (a: T, b: T) => itemProp(a).localeCompare(itemProp(b)) ) /** 降序排序 */ export const descendingSort = (itemProp: (obj: T) => number = selfSorter) => ( (a: T, b: T) => itemProp(b) - itemProp(a) ) /** 字符串降序排序 */ export const descendingStringSort = (itemProp: (obj: T) => string = selfSorter) => ( (a: T, b: T) => itemProp(b).localeCompare(itemProp(a)) )