sort the dictionary to avoid deadlocks