Friday, 27 September 2013

Accumulating data in sorted manner in Ruby

Accumulating data in sorted manner in Ruby

I am a bit new to Ruby and OOP.
I want to store triples of data associated with key. I have triples of
this form:
"data1" "data2" "data3", where data1 is an integer.
I have a mechanism to triples to key.
For example "key1" is mapped to ["data1", "data2", "data3"].
There can be multiple triples associated with key:
[4, "data2", "data3"], [1, "data5", "data6"] and [3, "data8", "data9"] are
mapped to "key1".
I want these triples to be mapped in a sorted way of "data1" field. In
this case,
"key1" => {[1, "data5", "data6"] [3, "data8", "data9"] [4, "data2",
"data3"]}
How do I do this Ruby?

No comments:

Post a Comment