Let's say I have a hash in Ruby like this:
d = {1 => 'one', 3 => 'three', 2 =>'two'}
and I wish to get
x = [1, 2, 3]
y = ['one', 'two', 'three']
that is, I want the sorted keys in x
, and the corresponding values in y
. I potentially want to use a custom sort order for x
.
What's the cleanest, simplest way to do this?