Ruby Forum Ruby on Rails > Order

Posted by Shandy Nantz (snantz)
on 19.08.2008 22:33
I have a list of user's email addresses that I am alphabetically
ordering. The issue is that the first 75 or so email addresses are in
order and then the order starts over again. Is that normal and is there
a way not to get my find to do that, to get it to order all the
addresses? Thanks,

-S
Posted by Jeff Cohen (jeff)
on 19.08.2008 22:56
(Received via mailing list)
On Aug 19, 3:33 pm, Shandy Nantz <rails-mailing-l...@andreas-s.net>
wrote:
> I have a list of user's email addresses that I am alphabetically
> ordering. The issue is that the first 75 or so email addresses are in
> order and then the order starts over again. Is that normal and is there
> a way not to get my find to do that, to get it to order all the
> addresses? Thanks,
>
> -S
> --
> Posted viahttp://www.ruby-forum.com/.

Wild guess, but perhaps you're not doing a case-insensitive sort?  In
which case you'll get A through Z, then a through z again.

Jeff

REST with Rails
Oct 4, 2008, Austin Tx
http://www.purpleworkshops.com/workshops/rest-and-web-services
Posted by Shandy Nantz (snantz)
on 20.08.2008 16:26
> Wild guess, but perhaps you're not doing a case-insensitive sort?  In
> which case you'll get A through Z, then a through z again.
> 
> Jeff
> 
> REST with Rails
> Oct 4, 2008, Austin Tx
> http://www.purpleworkshops.com/workshops/rest-and-web-services

No, everything is saved in all uppercase. Here is how I get my list:

 @users = User.find( :all, :conditions => ['approved = ?', true],
    :order => 'company ASC, username ASC')

All users are save with a comapnt field specifying who they work for and 
this field is also saved in all uppercase. In my view I loop through and 
pull out all the users working for a particular company. Everything 
thing get printed correctly - companies are found and all their users 
are displayed underneath their heading. However, I one company in 
particular, there are a lot of profiles and for this company is where I 
find this phenomenon. Here is how I loop through the profiles:

      <% company_name = "" %>
      <div>
  <table>
    <% @users.each do |x|

      if x.primary_account_id != company_name
      company_name = x.primary_account_id %>
    <tr>
      <th><%= x.company %></th>
    </tr>
                <tr>
        <td>
          <%=link_to x.username, {:action =>
                        'update_form', :controller => 'enroll', :id => 
x.id,
                        :manager => x.role == "Travel Manager" ? x.id : 
'',
                        :admin => @user.id}, :target => "_blank" %>

        </td>
    </tr>
         ...........
         </table>
       </div>