📜  角度键值管道 compareFn 示例 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:04:08.428000             🧑  作者: Mango

代码示例1
// Preserve original property order
originalOrder = (a: KeyValue, b: KeyValue): number => {
  return 0;
}

// Order by ascending property value
valueAscOrder = (a: KeyValue, b: KeyValue): number => {
  return a.value.localeCompare(b.value);
}

// Order by descending property key
keyDescOrder = (a: KeyValue, b: KeyValue): number => {
  return a.key > b.key ? -1 : (b.key > a.key ? 1 : 0);
}