public static function sort(ArrayList &$list, Comparator $comparator)
    {
        $array = $list->toArray();
        usort($array, [$comparator, "compare"]);
        $list->replace($array);
        return $list;
    }
public static function sort(ArrayList &$list, Comparator $comparator)
    {
        $array = $list->toArray();
        usort($array, [$comparator, "compare"]);
        $list->replace($array);
        return $list;
    }
public static function sort ( ArrayList & $ list , Comparator $ comparator ) { $ array = $ list -> toArray ( ) ; usort ( $ array , [ $ comparator , "compare" ] ) ; $ list -> replace ( $ array ) ; return $ list ; }
Sorts the specified list according to the order induced by the specified comparator. All elements in the list
must be mutually comparable.

@param ArrayList $list
@param Comparator $comparator
@return ArrayList
Sorts the specified list according to the order induced by the specified comparator . All elements in the list must be mutually comparable .