I note that not only is the lowest valued key the first key, but that other changes were made as well, e.g., 1,3,2 became 3,1,2. Interestingly, you are willing to break the key-value relations.
As such, taking the requirement as "lowest key value is now the highest (first)", a possible solution is:
$keys = array_keys($array);
$values = array_values($array);
sort($keys);
$array = array_combine($keys, $values);
If the keys 1,3,2 becoming 3,1,2 was a typographical error and you wish to maintain that order, then perhaps:
$keys = array_keys($array);
$values = array_values($array);
// Find lowest valued key.
$min = 0;
$count = count($keys);
for ($i = 1; $i < $count; ++$i)
{
if ($keys[$i] < $keys[$min])
{
$min = $i;
}
}
// Swap lowest valued key with first key.
$temp = $keys[0];
$keys[0] = $keys[$min];
$keys[$min] = $temp;
// Map the keys with the values to rebuild the original array.
$array = array_combine($keys, $values);
There is a third possibility, namely that you want to shift the lowest valued key to the first position and move those above it down. In that case, you would substitute the swap with:
$min_value = $keys[$min];
unset($keys[$min]);
array_unshift($keys, $min_value);