children); $i++) { $tmp = $this->children[$i]; $j = $i - 1; // Déplacez les éléments du tableau qui sont plus grands que la clé à une position devant leur position actuelle while($j >= 0 && $this->children[$j]->getPosition() > $tmp->getPosition()) { $this->children[$j + 1] = $this->children[$j]; $j--; } $this->children[$j + 1] = $tmp; } foreach($this->children as $child) { if(count($child->children) > 0) { $child->sortChildren($reindexation); } } if($reindexation){ $this->reindex(); } } // nouvelles positions (tableau $children => BDD) public function reindex(): void { $i = 1; foreach($this->children as $child){ $child->setPosition($i); $i++; } } }