# Order

**URL:** <https://www.ruby-forum.com/t/order/146307>\
**Category:** Rails\
**Created:** [August 19, 2008, 10:33pm UTC](https://www.ruby-forum.com/t/order/146307 "2008-08-19T22:33:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![snantz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c2a13f/32.png) [@snantz](https://www.ruby-forum.com/u/snantz)\
**Post date:** [August 19, 2008, 10:33pm UTC](https://www.ruby-forum.com/t/order/146307/1 "2008-08-19T22:33:11Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![snantz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c2a13f/32.png) [@snantz](https://www.ruby-forum.com/u/snantz)\
**Post date:** [August 19, 2008, 10:56pm UTC](https://www.ruby-forum.com/t/order/146307/2 "2008-08-19T22:56:46Z")

</div>

On Aug 19, 3:33 pm, Shandy N. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
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](http://www.purpleworkshops.com/workshops/rest-and-web-services)

---

<div class="post-metadata">

**Author:** ![snantz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c2a13f/32.png) [@snantz](https://www.ruby-forum.com/u/snantz)\
**Post date:** [August 20, 2008, 4:26pm UTC](https://www.ruby-forum.com/t/order/146307/3 "2008-08-20T16:26:51Z")

</div>

> 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](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>

```

 \<% @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>

```
