correctly sort list of hashes