ixfx
    Preparing search index...

    Function sortByValue

    • Returns a array of entries from a map, sorted by value.

      const m = new Map();
      m.set(`4491`, { name: `Bob` });
      m.set(`2319`, { name: `Alice` });

      // Compare by name
      const comparer = (a, b) => defaultComparer(a.name, b.name);

      // Get sorted values
      const sorted = Maps.sortByValue(m, comparer);

      sortByValue takes a comparison function that should return -1, 0 or 1 to indicate order of a to b. If not provided, Util.defaultComparer is used.

      Type Parameters

      • K
      • V

      Parameters

      • map: ReadonlyMap<K, V>
      • Optionalcomparer: (a: V, b: V) => number

      Returns [K, V][]