Ruby function to fetch, filter, and generate data
Matthew, it appears to me that you are only making use of the two elements of data whose keys are the top two in the sort.  Please correct me if I am wrong.  If that is the case, I believe your code (after "edit") can be simplified to this:

  def self.fetch_data(company)
    data = Provider::GenericProvider.create_provider(company['type'].to_sym, company).data
    data = data.sort {|(k1,_),(k2,_)| -(k1&lt;=&gt;k2)}.first(2)
    loop do
      break if :done == choose {|menu| timesheet_menu data, data.map(&amp;:first), menu}
    end
    Hash[data]
  end


Note that after the sort, data is an array of two 2-tuples, each corresponding to a key-value pair from the original hash.  If I misunderstood what you are doing, and you do need to pull out the 10 elements of the hash corresponding to the 10 highest-ranking keys, just change the parameter for first from 2 to 10, then extract the first two elements when you need them (i.e., data.first(2)).  You can then retrieve the key values from these 2-tuples or convert data.first(2) to a hash for the return value, as I have done with data.

Edit: Ah, valid_keys is modified by choose. Consider this as a further possibility:

 data = Hash[data.sort{|(a, _), (b, _)| -(a &lt;=&gt; b)}.first(10)]

 loop do
   break if (keys_chosen = choose {|menu| timesheet_menu data, data.keys.first(2), menu})
 end

 data.select {|k, _| keys_chosen.include? k}