I\'ve found a few answers to sorting by value, but not key.
What I\'d like to do is a reverse sort, so with:
$nametocode[\'reallylongname\']=\'12
In PHP7+ you can use uksort() with spaceship operator and anonymous function like this:
uksort()
uksort($array, function($a, $b) { return strlen($b) <=> strlen($a); });