Friday, June 10, 2011

[Rails] Re: Sorting Text in ROR

Thanks Walter and Kendall.

But ouput which I get using sort mentioned is as follows

>> a = [ "A Sharma", "A. Zah", "Aarti Jain", "A. Bansal", "Bindu Lakra" ]
=> ["A Sharma", "A. Zah", "Aarti Jain", "A. Bansal", "Bindu Lakra"]
>> a.sort {|x,y| y <=> x}
=> ["Bindu Lakra", "Aarti Jain", "A. Zah", "A. Bansal", "A Sharma"]

I want my sort to skip "." and spaces while sorting.

My intended output is
=> ["Aarti Jain", A. Bansal", "A Sharma","A. Zah", "Bindu Lakra" ]


Is there any way to get it sorted the way i wanted where . and space
is not considered while sorting?

--
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 this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate