title: How do I order a has_many through association in Ruby on Rails?
body: <p>Given the following AR models, I would like to sort users alphabetically by last name when given a handle to a task:</p>
  
  <pre><code>#user
  has_many :assignments
  has_many :tasks, :through =&gt; :assignments    
  
  #assignment
  belongs_to :task
  belongs_to :user
  
  #task
  has_many :assignments
  has_many :users, :through =&gt; :assignments
  </code></pre>
  
  <p>I would like to get a task then navigation to its assigned users, <em>and sort the user list alphabetically</em>.</p>
  
  <p>I keep thinking that I should be able to add the <code>:order</code> clause to <code>has_many :users, :through =&gt; :assignments</code> like this:</p>
  
  <pre><code>#task.rb
  has_many :assignments
  has_many :users, :through =&gt; :assignments, :order =&gt; 'last_name, first_name'
  </code></pre>
  
  <p>however this does not work.</p>
  
  <p>How can I sort users by <code>last_name</code> when given a task?</p>