There are two ways that a pair of two-dimensional hashes can be 'equal'. Corresponding values in all the inner hashes have equal values or the corresponding values in the outer hashes refer to the same set of inner hashes. (The later of course implies the first) You may want to require (or exclude) the latter.