title: Complex sorting for search in realm, union of multiple RealmResults
body: <p>I replaced sqlite with realm in my open source Linux Command Library project. Everything went fine so far, but now I'm facing a problem.</p>
  
  <p>I'm using a RealmBaseAdapter to display all the commands in a ListView with an search interface. For a search the realm sniped below orders the results like this:</p>
  
  <p>Query: 
  <strong>test</strong></p>
  
  <p>result:</p>
  
  <ul>
  <li>l2<strong>test</strong> </li>
  <li>rc<strong>test</strong></li>
  <li><strong>test</strong></li>
  <li><p><strong>test</strong>parm</p>
  
  <pre><code>RealmResults&lt;Command&gt; commands = mRealm.where(Command.class).contains("name", query).findAll();
  mAdapter.updateRealmResults(commands);
  </code></pre></li>
  </ul>
  
  <p>With the old sqlite logic the order was like this:</p>
  
  <p>result:</p>
  
  <ul>
  <li><strong>test</strong></li>
  <li><strong>test</strong>parm</li>
  <li>l2<strong>test</strong> </li>
  <li>rc<strong>test</strong></li>
  </ul>
  
  <p><code>return getReadableDatabase().rawQuery("Select * from " + CommandsDBTableModel.TABLE_COMMANDS + " WHERE " + CommandsDBTableModel.COL_NAME + " LIKE '%" + query + "%' " + "ORDER BY " + CommandsDBTableModel.COL_NAME + " = '" + query + "' DESC," + CommandsDBTableModel.COL_NAME + " LIKE '" + query + "%' DESC", null);</code></p>
  
  <p>Is it possible to realize it with realm too? 
  Here is the link to the project <a href="https://github.com/SimonSchubert/LinuxCommandBibliotheca" rel="nofollow">https://github.com/SimonSchubert/LinuxCommandBibliotheca</a></p>