I got the answer.

Wrote like this

array.sort_by {|i| str_to_num(i[0]) } &

  def str_to_num(str)
    code = str.split('_')[2]
    regex = Regexp.new "^question_(\\d+)_#{code}_(\\d+)$"
    str =~ regex
    [$1.to_i, $2.to_i]
  end


Thanks
Avantec

-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to