title: Ruby on Rails / Active Record: Custom Sorting Order
body: <p>I have a query that can be sorted by date or name.</p>
  
  <p>I also have a URL parameter which is the ID of a specific record. I need to move this record to the top of the list, but keep the rest unchanged.</p>
  
  <p>For example:</p>
  
  <p>if param = 2, then return [2, 1, 3, 4, 5, 6, 7, 8]</p>
  
  <p>if param = 5, then return [5, 1, 2, 3, 4, 6, 7, 8]</p>
  
  <p>if param = 7, then return [7, 1, 2, 3, 4, 5, 6, 8]</p>
  
  <p>... etc.</p>
  
  <p>I know how to do it with an array, but can I do it with Active Record too? Because I need to do pagination etc. after that.</p>
  
  <p>Thanks!</p>