showing results for - "angular key value pipe comparefn example"
Hannah
16 Oct 2020
1// Preserve original property order
2originalOrder = (a: KeyValue<number,string>, b: KeyValue<number,string>): number => {
3  return 0;
4}
5
6// Order by ascending property value
7valueAscOrder = (a: KeyValue<number,string>, b: KeyValue<number,string>): number => {
8  return a.value.localeCompare(b.value);
9}
10
11// Order by descending property key
12keyDescOrder = (a: KeyValue<number,string>, b: KeyValue<number,string>): number => {
13  return a.key > b.key ? -1 : (b.key > a.key ? 1 : 0);
14}
15