in reply to hashes with multiple keys
One strategy might be to first extract the data into a flat-file, then sort that file. Identical keys are now adjacent.