The key is the 7 to the power of ord(char) bitwise 30 part. I had to write a little perl script that would find the magic values 7 and 30 which would work for a lexicographic (default) sort. That is, I take 7 to the power of those values, and subtract the value of $` ... to produce hash keys which sort properly.
Then I take a hash slice on the sorted result. The sort actually returns the entire flattened hash sorted, keys and values, but since the values in that hash don't map to anything, they are silent.