Modified so that hashes are sorted