# Order in list

**URL:** <https://www.ruby-forum.com/t/order-in-list/126438>\
**Category:** Rails\
**Created:** [January 18, 2008, 9:03am UTC](https://www.ruby-forum.com/t/order-in-list/126438 "2008-01-18T09:03:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![captaffy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/f04885/32.png) [@captaffy](https://www.ruby-forum.com/u/captaffy)\
**Post date:** [January 18, 2008, 9:03am UTC](https://www.ruby-forum.com/t/order-in-list/126438/1 "2008-01-18T09:03:17Z")

</div>

I have this code:

\<% form\_for(@repair\_ticket) do |f| %\>

\<%= text\_field\_with\_auto\_complete :rp\_part, :name %\>

**Client**  
 \<% @clients.each do |client| %\> \> \<%= client.name %\> \<% end %\>

How can I ;order =\> client.name all the results in the list ?

---

<div class="post-metadata">

**Author:** ![captaffy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/f04885/32.png) [@captaffy](https://www.ruby-forum.com/u/captaffy)\
**Post date:** [January 18, 2008, 9:34am UTC](https://www.ruby-forum.com/t/order-in-list/126438/2 "2008-01-18T09:34:00Z")

</div>

John S. wrote:

> I have this code:
> 
> \<% form\_for(@repair\_ticket) do |f| %\>
> 
> \<%= text\_field\_with\_auto\_complete :rp\_part, :name %\>
> 
> **Client**  
> \<% @clients.each do |client| %\> \> \<%= client.name %\> \<% end %\>
> 
> How can I ;order =\> client.name all the results in the list ?

in the controller:

@clients = Client.find(:all, :order =\> ‘name’)

in the view:

f.select :client\_id, @clients.map{|c| [c.name, c.id]}
