title: rails activerecord order in group
body: <p>I want to display the latest version(<strong>version is float: 1, 1.1, 1.2...</strong>) in every result group.
  here is my code:</p>
  
  <pre><code>@results = Result.where(project_id: @project_id).group(:result_id).order("result_version DESC")
  </code></pre>
  
  <p>and in rails server message:</p>
  
  <pre><code>SELECT  `results`.* FROM `results` WHERE `results`.`project_id` = 2 GROUP BY `results`.`result_id`  ORDER BY result_version DESC LIMIT 5 OFFSET 0
  </code></pre>
  
  <p>but it's not work, so I try <strong>ASC</strong>:</p>
  
  <pre><code>@results = Result.where(project_id: @project_id).group(:result_id).order(:result_version)
  </code></pre>
  
  <p>message:</p>
  
  <pre><code>SELECT  `results`.* FROM `results` WHERE `results`.`project_id` = 2 GROUP BY `results`.`result_id`  ORDER BY `results`.`result_version` ASC LIMIT 5 OFFSET 0
  </code></pre>
  
  <p>in view, two method show the same thing(<strong>order by ASC</strong>).
  how can I do order in the group?</p>
  
  <p>data like this:</p>
  
  <pre><code>id, project_id, result_version, result_id, result_num
  '6',   '2',          '1',         '1',     'N00009999000010'
  '7',   '2',          '1',         '2',     ‘N00009999000020'
  '8',   '2',          '1',         '3',     'N00009999000030'
  '10',  '2',          '1.1',       '2',     'N00009999000020'
  '11',  '2',          '1.1',       '3',     'N00009999000030'
  </code></pre>
  
  <p>P.S. if simply use .order(result_version: :desc), it work.
  my problem just like this issue:
  <a href="https://stackoverflow.com/questions/6468316/maximum-in-group-by-active-record-query">Maximum in group by active record query</a>
  but it's answer can't solve my problem.</p>