This API is part of the Hack Standard Library, not HHVM itself.

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

namespace HH\Lib\Dict;

function sort_by_key<Tk as arraykey, Tv>(
    KeyedTraversable<Tk, Tv> $traversable,
  ?(function(Tk,Tk):int) $key_comparator = NULL,
): dict<Tk, Tv>;

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

  • To sort by the values of the KeyedTraversable, see Dict\sort().
  • To sort by some computable property of each value, see Dict\sort_by().