sort dictionary keys before comparison, ordering is not guaranteed