From: "Williams, Chris" Date: 2004-12-14T05:07:03+09:00 Subject: [Nuby] Sorting a Hash and keepint it as a Hash? ------_=_NextPart_001_01C4E14F.4AE3BE3B Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Another nuby question: I have a Hash of objects which I want to sort by the values. Afterwards I want to pull out the keys as one array and the values as another. So I have code like so: # sort by frequency ascending @fault_sums =3D @fault_sums.sort {|a,b| a[1] <=3D> b[1]} # Only keep top N @fault_sums.slice!(0...-@number) if @number <=3D @fault_sums.size=20 =20 fields =3D @fault_sums.keys data =3D @fault_sums.values But when I get to calling keys and values on the Hash I realized, sort actually returns back a 2D array and those methods aren't defined on an Array. Is there a way to make the 2D Array returned by the sort back into a Hash? Thanks, Chris Williams ------_=_NextPart_001_01C4E14F.4AE3BE3B--