Sorts the given object by a comparator.

Type signature

<T>(f: (a: T, b: T) => number) => (xs: GenericObject<T>) => GenericObject<T>

Examples

sort({
  a: 3,
  b: 2,
  c: 3,
  d: -7,
  e: 13,
  f: 0,
  g: 8,
});
// ⇒ {"d": -7,"f": 0,"b": 2,"a": 3,"c": 3,"g": 8,"e": 13}
Try in REPL

Questions

  • How to sort an object?

TypeScript sourceJavaScript source