When using the Angular keyvalue pipe to iterate over an object\'s properties as follows:
I think this is a cleaner solution. Uncomment the return statement that needs to give the right order:
interface KeyValue {
key: K,
value: V
}
// Order by descending property key
keyOrder = (aA: KeyValue, bB: KeyValue): number => {
const a = aA.value.index;
const b = bB.value.index;
//return a > b ? 1 : (b > a ? -1 : 0); // ASCENDING
return a > b ? -1 : (b > a ? 1 : 0); // DESCENDING
}
USE CASE
{{ x.key }} indexes: {{ x.value.index }}