/** * Initializes SortedList ensuring that elements are in fact a sorted list. * * @param array $elements * @param boolean $sortElements If true, elements will be sorted when creating the list */ public function __construct(array $elements = [], $sortElements = true) { parent::__construct($elements); if ($sortElements) { usort($this->elements, [$this, 'compare']); } }