title: Forcing a particular order in Rails model scope
body: <p>I have a Model <code>M</code> in my rails code. It has a field <code>F</code> which can have 4 values <code>D</code>, <code>J</code>, <code>M</code> and <code>Z</code></p>
  
  <p>If I use a scope like this, it would sort data by field <code>F</code> alphabetically:</p>
  
  <pre><code>default scope {order (F: :asc)}
  </code></pre>
  
  <p>I have 2 questions here:</p>
  
  <ol>
  <li><p>I don't want to sort data alphabetically on <code>F</code>. I would like data to be displayed with this particular order of <code>F</code> instead. I want ALWAYS the records containing value <code>M</code> for field <code>F</code> first, follow by records having value <code>J</code>,  <code>D</code> and then <code>Z</code> in this order. How can I achieve this?</p></li>
  <li><p>Suppose I would like to display records having <code>J</code> first and then sort the rest of the records by alphabetical order of field <code>F</code>, how can I do that?</p></li>
  </ol>