# Find find company name and user name

**URL:** <https://www.ruby-forum.com/t/find-find-company-name-and-user-name/136066>\
**Category:** Rails\
**Created:** [April 28, 2008, 5:30pm UTC](https://www.ruby-forum.com/t/find-find-company-name-and-user-name/136066 "2008-04-28T17:30:33Z")\
**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:** [April 28, 2008, 5:30pm UTC](https://www.ruby-forum.com/t/find-find-company-name-and-user-name/136066/1 "2008-04-28T17:30:33Z")

</div>

I have this list of registered users which I find by a find statment in  
my controller:

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

Then in my view I run through this array and get all the registered  
users for each company and print them out in a nice, easy to read list.  
I am order in ascending order by company, but I would also like to order  
the users for each company in ascending order as well. I am not exactly  
sure where to start with this. I think this might be a hashing issues  
but I am not really sure. In line with that thinking, does the above  
find save “stuff” in a hash or a strait forward array? Any suggestions?  
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:** [April 28, 2008, 5:50pm UTC](https://www.ruby-forum.com/t/find-find-company-name-and-user-name/136066/2 "2008-04-28T17:50:53Z")

</div>

On 28 Apr 2008, at 16:30, Shandy N. wrote:

> list.  
> I am order in ascending order by company, but I would also like to  
> order  
> the users for each company in ascending order as well. I am not  
> exactly  
> sure where to start with this.

Is :order =\> ‘company asc, name asc’ what you mean

> I think this might be a hashing issues  
> but I am not really sure. In line with that thinking, does the above  
> find save “stuff” in a hash or a strait forward array? Any  
> suggestions?  
> Thanks,

It returns an array

---

<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:** [April 28, 2008, 6:02pm UTC](https://www.ruby-forum.com/t/find-find-company-name-and-user-name/136066/3 "2008-04-28T18:02:16Z")

</div>

Frederick C. wrote:

> On 28 Apr 2008, at 16:30, Shandy N. wrote:
> 
> > list.  
> > I am order in ascending order by company, but I would also like to  
> > order  
> > the users for each company in ascending order as well. I am not  
> > exactly  
> > sure where to start with this.
> 
> Is :order =\> ‘company asc, name asc’ what you mean
> 
> > I think this might be a hashing issues  
> > but I am not really sure. In line with that thinking, does the above  
> > find save “stuff” in a hash or a strait forward array? Any  
> > suggestions?  
> > Thanks,
> 
> It returns an array

Actually, that does exactly what I want, I just thought that it wouldn’t  
be that simple. I guess I fugured that trying to order on two fields  
might cause some issues with order under one company and there order  
under and different company, but I guess not. Thanks for your help.
