From: Joao Silva Date: 2008-12-10T19:17:59+09:00 Subject: Re: want to search value in nested arrays and return other v Pierre Pat wrote: > Are you the one defining the data structure? > Or is it something you just have to use the way it is? > > Because in this case, a hashmap would make more sense I believe. I need exactly this structure because it is used in options_for_select() in Rails Framework, so i can't change this. A hash is unsorted, and I need this sorted. botp wrote: > did you really check that? it will always return "value 1" ;) erm, right :) I meant 'v[1] == value' - thats how I tried it out on my computer :) > def value_name3(value) > VALUES.each{|k,v| return k if v== value} > "" > end Thank you very much, that does the task and works as I wanted to have it. -- Posted via http://www.ruby-forum.com/.