Meta Engineer?

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

Returns a new keyset sorted by the values of the given Traversable

namespace HH\Lib\Keyset;

function sort<Tv as arraykey>(
  Traversable<Tv> $traversable,
  ?(function(Tv, Tv): num) $comparator = NULL,
): keyset<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 explicitly provided) Space complexity: O(n)



  • keyset<Tv>