title: Sorting on association with has_many_through relation
body: <p>I Want to get sorted result using price.</p>
  
  <blockquote>
    <p>I want to get result with sorting order by price when i do
    <code>hotel.packages</code></p>
  </blockquote>
  
  <p>I have two models<code>(hotel and package )</code> with <code>has_many :through</code> relationship. both are connected to each other with through relationship and its model name is <code>package_price</code></p>
  
  <p>Hotel model is:</p>
  
  <pre><code> class Hotel &lt; ActiveRecord::Base  
      has_many :package_prices, :dependent =&gt; :destroy 
      has_many :packages, :through =&gt; :package_prices, :order =&gt; 'package_prices.price'
    end
  </code></pre>
  
  <p>package model is: </p>
  
  <pre><code>class Package &lt; ActiveRecord::Base
      has_many :package_prices, :dependent =&gt; :destroy #foreign key package_id
      has_many :hotels, :through =&gt; :package_prices, :order =&gt; 'package_prices.price'
  end
  </code></pre>
  
  <p>package_price model is:</p>
  
  <pre><code>class PackagePrice &lt; ActiveRecord::Base
    belongs_to :package
    belongs_to :hotel
  end
  </code></pre>
  
  <p>package_prices table fields:</p>
  
  <pre><code>+------------+--------------+------+-----+---------+----------------+
  | Field      | Type         | Null | Key | Default | Extra          |
  +------------+--------------+------+-----+---------+----------------+
  | id         | int(11)      | NO   | PRI | NULL    | auto_increment |
  | package_id | int(11)      | YES  |     | NULL    |                |
  | price      | int(11)      | YES  |     | NULL    |                |
  | hotel_id   | varchar(255) | YES  |     | NULL    |                |
  | created_at | datetime     | NO   |     | NULL    |                |
  | updated_at | datetime     | NO   |     | NULL    |                |
  +------------+--------------+------+-----+---------+----------------+
  </code></pre>
  
  <p>I want to get packages of hotel by sorted with price.</p>