Meta Engineer?

This is available as Dict\sort in the www repository.

Returns a new dict sorted by the values of the given KeyedTraversable

namespace HH\Lib\Dict;

function sort<Tk as arraykey, Tv>(
  KeyedTraversable<Tk, Tv> $traversable,
  ?(function(Tv, Tv): num) $value_comparator = NULL,
): dict<Tk, Tv>;

If the optional comparator function isn't provided, the values will be sorted in ascending order.

Time complexity: O((n log n) * c), where c is the complexity of the comparator function (which is O(1) if not provided explicitly) Space complexity: O(n)



  • dict<Tk, Tv>