There is a PHP function call uasort that lets you define a function to sort an array and maintain array key ordering.
The return value of your defined function must be 0, -1 or 1 depending on if the values are the same, if the second value is less than the first value, or if the second value is greater than the first value, respectively.
To achieve what you are attempting would require a function similar to:
$array = array(4,0,2,0,3);
uasort($array, function($a,$b) {
// push all 0's to the bottom of the array
if( $a == 0 ) return 1;
if( $b == 0 ) return -1;
if($a == $b) {return 0; } // values are the same
return ($a < $b) ? -1 : 1; // smaller numbers at top of list
});
var_dump($array);
/*
array (size=5)
2 => int 2
4 => int 3
0 => int 4
3 => int 0
1 => int 0
*/