PHP ksort() Function

The ksort() function sorts an associative array in ascending order, according to the key.ksort — Sort an array by key.Sorts an array by key, maintaining key to data correlations. This is useful mainly for associative arrays.

Example -