/** * @param DoubleLinkedList $list */ public function insertionSort(DoubleLinkedList $list) { $current = $list->getBottom(); while ($current) { $selectedToCompare = $current->getNext(); while ($selectedToCompare) { if ($current->getData() > $selectedToCompare->getData()) { $this->swap($selectedToCompare, $current); } $selectedToCompare = $selectedToCompare->getNext(); } $current = $current->getNext(); } }