title: Move x element to the end of an array
body: <p>I'm trying to find a method to take a particular relation and move it to the end of the array. Basically, I have a <code>current_account</code> and I want to take this account and move it to the end of the account relationship array so that it will display last when I iteration over the relationships. I want to make a scope and use SQL if possible, here is my attempt and I haven't really gotten anywhere.</p>
  
  <p>HTML</p>
  
  <pre><code>&lt;% current_user.accounts.current_sort(current_account).each do |account| %&gt;
     &lt;li&gt;&lt;%= link_to account.name, switch_account_accounts_path(account_id: account.id) %&gt;&lt;/li&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>This current return a list of sorted by created_at accounts. I don't want it to be sorted by created at but the <code>current_account</code> to be at the bottom so I make a scope called <code>current_sort</code> but I'm not sure what to do here.</p>
  
  <p>CURRENT_SORT SCOPE ON ACCOUNT</p>
  
  <pre><code> scope :current_sort, lambda { |account|
  
   }
  </code></pre>
  
  <p>I want this scope to return the passed in account last in the association array. How can I do this with SQL or Ruby? </p>