public static function sort(ArrayList &$list, Comparator $comparator)
    {
        $array = $list->toArray();
        usort($array, [$comparator, "compare"]);
        $list->replace($array);
        return $list;
    }