getValue() < $item->getValue()) { ++$pos; } } if ($pos === $start) { continue; } while ($item->getValue() === $list[$pos]->getValue()) { ++$pos; } $old = $list[$pos]; $list[$pos] = $item; $item = $old; ++$writes; while ($pos !== $start) { $pos = $start; $length1 = \count($list); for ($i = $start + 1; $i < $length1; ++$i) { if ($list[$i]->getValue() < $item->getValue()) { ++$pos; } } while ($item->getValue() === $list[$pos]->getValue()) { ++$pos; } $old = $list[$pos]; $list[$pos] = $item; $item = $old; ++$writes; } } return $order === SortOrder::ASC ? $list : \array_reverse($list, false); } }