Check out example codes for "is there a way of changing the key of a hash". It will help you in understanding the concepts better.

Code Example 1

hash.to_a.transpose.map(&:sort).transpose.to_h

Learn ReactJs, React Native from akashmittal.com