title: Sort in Ascending Order Rails
body: <p>Hi I have this model    </p>
  
  <p>Model item</p>
  
  <pre><code>class Inventory::Item &lt; ActiveRecord::Base
    has_many :types, :class_name =&gt; "ItemType"
    attr_accessible :name
  end
  </code></pre>
  
  <p>Model item_type</p>
  
  <pre><code>class Inventory::ItemType &lt; ActiveRecord::Base
    belongs_to :item 
    attr_accessible :number
  end
  </code></pre>
  
  <p>then let say in controller I want to sort types (which has class ItemType) in ascending order based on Item name. How do I do that?</p>
  
  <p>For example, 
   <ul>
      <li>ItemType number = 1 has Item name = Table</li>
      <li>ItemType number = 2 has Item name = Chair</li>
      <li>ItemType number = 3 has Item name = Window</li>
      <li>ItemType number = 4 has Item name = Computer</li>
   </ul></p>
  
  <p>So instead of sorting it from number, I want it sorted based on item.name(ASC) like this:
   <ul>
      <li>ItemType number = 2 has Item name = Chair</li>
      <li>ItemType number = 4 has Item name = Computer</li>
      <li>ItemType number = 1 has Item name = Table</li>
      <li>ItemType number = 3 has Item name = Window</li>
   </ul></p>