PHP排序数字全为零而不更改索引

The asort(arrivalTime[]) is not correct. How to correct this when I put all zero on all? The display is:

Array
(
    [4] => 0
    [3] => 0
    [2] => 0
    [1] => 0
    [0] => 0
)

it should be like this and not affecting the index... cause no need to sort when all zero...

Array
(
    [0] => 0
    [1] => 0
    [2] => 0
    [3] => 0
    [4] => 0
)

and when I input another with there is not zero this will the result

Array
(
    [0] => 0
    [2] => 0
    [1] => 0
    [3] => 1
    [4] => 2
)

can anyone have another solution?

EDIT when I used ksort() this is the result... when I input 0, 2, 1 and this is the simple code

<?php
    $test = array(0,2,1);
    ksort($test);
    echo "<pre>";
    print_r($test);
    echo "</pre>";
?>

the output is bug

Array
(
    [0] => 0
    [1] => 2
    [2] => 1
)

all I want is when I put 0,0,0,1 and not changing the key because it's the same...

Array
(
    [0] => 0
    [1] => 0
    [2] => 0
    [3] => 0
)

then another input is 0,2,1,3

Array
(
    [0] => 0
    [2] => 1
    [1] => 2
    [3] => 3
)

use ksort() function to sort your arrays by their keys.

To your question use the ksort(), as the manual.

ksort(arrivalTime[]);

Array
(
    [0] => 0
    [1] => 0
    [2] => 0
    [3] => 0
    [4] => 0
)

Sorts an array by key, maintaining key to data correlations.

$test = array(0,2,1,3);
arsort($test);
echo "<pre>";
print_r($test);
echo "</pre>";

$test = array(0,0,0,1);
ksort($test);
echo "<pre>";
print_r($test);
echo "</pre>";

if($test == array(0,0,0,1)){
    ksort($test);
} else{
    asort($test);
}
echo "<pre>";
print_r($test);
echo "</pre>";