How can the ksort function be used to sort an array numerically when the indexes are numeric values?

When the indexes of an array are numeric values and you want to sort the array numerically, you can use the `ksort` function in PHP. This function sorts an array by key while maintaining key to data correlations. By using `ksort` with the `SORT_NUMERIC` flag, you can achieve a numerical sort based on the keys of the array.

$array = [3 => 'apple', 1 => 'banana', 2 => 'orange'];
ksort($array, SORT_NUMERIC);
print_r($array);