Ruby 1.8: Hash # sort não retorna hash, mas array (melhor maneira de fazer isso?)

Em algum cenário do Ruby 1.8. Se eu tiver um hash

# k is name, v is order
foo = { "Jim" => 1, "bar" => 1, "joe" => 2}
sorted_by_values = foo.sort {|a, b| a[1] <==> b[1]}
#sorted_by_values is an array of array, it's no longer a hash!
sorted_by_values.keys.join ',' 

minha solução alternativa é fazer métodoto_hash para a classe Array.

class Array
  def to_hash(&block)
    Hash[*self.collect { |k, v|
      [k, v]
    }.flatten]
  end
end

Posso então fazer o seguinte:

sorted_by_values.to_hash.keys.join ','

Existe uma maneira melhor de fazer isso?

questionAnswers(1)

yourAnswerToTheQuestion