maintenance
This commit is contained in:
20
src/utility/sort.ts
Normal file
20
src/utility/sort.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
/**
|
||||
* Copyright 2024 Phenix Real Time Solutions, Inc. Confidential and Proprietary. All Rights Reserved.
|
||||
*/
|
||||
import {DirectionType} from 'interfaces/tableProps';
|
||||
|
||||
import {DataValueType} from 'components/table';
|
||||
|
||||
export const compare = (a: Record<string, DataValueType>, b: Record<string, DataValueType>, direction: DirectionType, propName: string): number => {
|
||||
if (a && b) {
|
||||
const isDesc = direction === DirectionType.Desc;
|
||||
|
||||
if (a[propName] < b[propName]) {
|
||||
return isDesc ? -1 : 1;
|
||||
} else if (a[propName] > b[propName]) {
|
||||
return isDesc ? 1 : -1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
};
|
||||
Reference in New Issue
Block a user