title: Rails, how to sort a collection keeping a specific value at the end
body: <p>I have an active record collection of some objects...</p>
  <pre><code>#&lt;CoverElement:0x00007f87a4d78718
    id: 312,
    title: &quot;Title 1&quot;,
    link: &quot;&quot;,
    coverable_id: 35001,
    coverable_type: &quot;Article&quot;,
    created_at: Thu, 07 May 2020 16:55:00 CEST +02:00,
    updated_at: Thu, 07 May 2020 16:55:00 CEST +02:00,
    cover_id: 4,
    format: &quot;small&quot;,
    custom_image: nil,
    position: 2,
    second_title: nil,
    second_title_url: nil&gt;,
   #&lt;CoverElement:0x00007f87a4d6fde8
    id: 313,
    title: &quot;Title 2&quot;,
    link: &quot;&quot;,
    coverable_id: 35010,
    coverable_type: &quot;Article&quot;,
    created_at: Thu, 07 May 2020 16:55:00 CEST +02:00,
    updated_at: Sun, 22 Nov 2020 19:33:39 CET +01:00,
    cover_id: 4,
    format: &quot;horizontal&quot;,
    custom_image: nil,
    position: 3,
    second_title: nil,
    second_title_url: nil&gt;
  </code></pre>
  <p>For the desktop version of the website I use the position as order, but I need another order for the mobile version.
  I need to sort by format and &quot;small&quot; must be the last.</p>
  <p>Basically formats can be: &quot;large&quot;, &quot;vertical&quot;, &quot;horizontal&quot; and &quot;small&quot;.</p>
  <p>I try with</p>
  <pre><code>@elements.reorder('format ASC')
  </code></pre>
  <p>and it works but of course it keep the order &quot;horizontal&quot;, &quot;large&quot;, &quot;vertical&quot; and &quot;small&quot;</p>
  <p>Every object with &quot;small&quot; as format must be at the end. Is there a way to do this or I have to write a custom sort method?</p>