Note : This function assigns new keys to the elements in array . It will remove any existing keys that may have been assigned, rather than just reordering the keys.
I would have guessed you wanted asort ^ maybe with a sort_flag. But if after looking at the examples and giving it a try you get the results you want, sure, sorting by keys could work.
I went with asort to start with and that sorts by the value. The value and key are going to start with the same letter but after that I may need to use a different letter depending on how many options I have. So the key would probably be the best bet but I will see how it goes.