Added some filtering to participant component

This commit is contained in:
Erik Tiekstra
2021-03-29 12:51:49 +02:00
committed by Erik Tiekstra
parent 99db911f39
commit 8a9b0049d4
5 changed files with 78 additions and 37 deletions
+12
View File
@@ -0,0 +1,12 @@
import { SortBy } from '@dafa-models/sort-by.model';
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export function sort(data: any[], sortBy: SortBy): any[] {
const reverse = sortBy.reverse ? -1 : 1;
return [...data].sort((a, b) => {
const first = a[sortBy.key];
const second = b[sortBy.key];
return reverse * (+(first > second) - +(second > first));
});
}