Re: Re: Sorting Text in ROR

Colin Law
Sat, 11 Jun 2011 06:37:58 -0000

On 11 June 2011 07:10, Runa
<roonadangui-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:
> 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" ]

You have not shown us the code you have used to do the sort so how can
we tell what is wrong with it?  Make sure you copy/paste it here
rather than re-type it so we can see exactly what you have done.  Just
the code for the sorting please.  First make sure you understand the
code you have used.  Can you see why it does not do what you want?

Colin

--
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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe@googlegroups.com.