src/Algorithm/Sorting/SelectionSort.php
public function sort(array $array): array {
        $array = \array_values($array);
        $length = \count($array);

        if (0 === $length || 1 === $length) return $array;

        for ($i = 0; $i < $length; $i++) {
            $min = $i;
            for ($j = $i; $j < $length; $j++) {
                if (Comparator::lessThan($array[$j], $array[$min])) {
                    $min = $j;
                }
            }
            $tmp = $array[$min];
            $array[$min] = $array[$i];
            $array[$i] = $tmp;
        }
        return $array;
    }
public function sort(array $array): array {
        $array = \array_values($array);
        $length = \count($array);

        if (0 === $length || 1 === $length) return $array;

        for ($i = 0; $i < $length; $i++) {
            $min = $i;
            for ($j = $i; $j < $length; $j++) {
                if (Comparator::lessThan($array[$j], $array[$min])) {
                    $min = $j;
                }
            }
            $tmp = $array[$min];
            $array[$min] = $array[$i];
            $array[$i] = $tmp;
        }
        return $array;
    }
public function sort ( array $ array ) : array { $ array = \ array_values ( $ array ) ; $ length = \ count ( $ array ) ; if ( 0 === $ length || 1 === $ length ) return $ array ; for ( $ i = 0 ; $ i < $ length ; $ i ++ ) { $ min = $ i ; for ( $ j = $ i ; $ j < $ length ; $ j ++ ) { if ( Comparator :: lessThan ( $ array [ $ j ] , $ array [ $ min ] ) ) { $ min = $ j ; } } $ tmp = $ array [ $ min ] ; $ array [ $ min ] = $ array [ $ i ] ; $ array [ $ i ] = $ tmp ; } return $ array ; }
sorts an array with selection sort.

Actually works only with numeric indices

@param array $array
@return array
sorts an array with selection sort .