http://www.ruby-doc.org/core/classes/Array.html#M000244
You want to either use the block form or define your own version of
<=> to use, stripping punctuation and downcasing the input for good
measure to create a "natural" sort.
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-
> ta...@googlegroups.com.
> To unsubscribe from this group, send email to rubyonrails-ta...@googlegroups.com
> .
> For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en
> .
>
On Jun 10, 2011, at 10:59 AM, Runa wrote:> While sorting /ordering text it considers space first, then '.' then
> characters
>
> e.g. @user = User.find(:all,:order=>'name')
>
> it outputs
>
> A Sharma
> A. Bansal ---------------with dot
> Aarti Dev
>
> Is there any way to sort, so that i get the output as
> Aarti Dev
> A. Bansal
> A Sharma
>
>http://www.ruby-doc.org/core/classes/Array.html#M000244
You want to either use the block form or define your own version of
<=> to use, stripping punctuation and downcasing the input for good
measure to create a "natural" sort.Walter
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