sorts the keys in char_fun