public function sort(array $array): array
    {
        if ($array === []) {
            return $array;
        }
        natsort($array);
        $i = 0;
        $newArray = [];
        foreach ($array as $key => $value) {
            if (is_string($key)) {
                $newArray[$key] = $value;
            } else {
                $newArray[$i] = $value;
                $i++;
            }
        }
        return $newArray;
    }
public function sort(array $array): array
    {
        if ($array === []) {
            return $array;
        }
        natsort($array);
        $i = 0;
        $newArray = [];
        foreach ($array as $key => $value) {
            if (is_string($key)) {
                $newArray[$key] = $value;
            } else {
                $newArray[$i] = $value;
                $i++;
            }
        }
        return $newArray;
    }
public function sort ( array $ array ) : array { if ( $ array === [ ] ) { return $ array ; } natsort ( $ array ) ; $ i = 0 ; $ newArray = [ ] ; foreach ( $ array as $ key => $ value ) { if ( is_string ( $ key ) ) { $ newArray [ $ key ] = $ value ; } else { $ newArray [ $ i ] = $ value ; $ i ++ ; } } return $ newArray ; }
Sorts an array

The sorting is done first by numbers, then by characters.

Internally natsort() is used as it most closely resembles javascript's sort().
Because there are no real associative arrays in Javascript, keys of the array will be preserved.

@param array $array
@return array The sorted array
Sorts an array