Method: Dictionary#order_by_value

Defined in:
lib/extlib/dictionary.rb

#order_by_valueObject

Keep dictionary sorted by value.

d = Dictionary.new.order_by_value
d["z"] = 1
d["y"] = 2
d["x"] = 3
d  #=> {"x"=>3,"y"=>2,"z"=>2}

This is equivalent to:

Dictionary.new.order_by { |key,value| value }


190
191
192
193
194
# File 'lib/extlib/dictionary.rb', line 190

def order_by_value
  @order_by = lambda { |k,v| v }
  order
  self
end