Try hard to sort hashes deterministically

When sorting two hashes, break ties for hashes with same set of keys by comparing values. Fixes introduction of random looking changes when modifying large YAML blocks containing arrays of hashes.