On Dec 8, 2012, at 4:53 AM, Avantec Van wrote:
> 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
>
I'm still curious why you needed these parameters to be in a particular order. It seems to be unusual in the Rails form-handling patterns to have this matter at all. It's a hash, and those don't have an explicit order anyway (until Ruby 1.9.3).
Walter
--
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 rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
No comments:
Post a Comment