title: How to sort elasticsearch resultset on the basis of field preference
body: <p>I have a requirement in which I have to sort elastic search data on the basis of fields.
  For Example, I have some docs indexed in elastic search as shown below.</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th style="text-align: left;">firstName</th>
  <th style="text-align: center;">lastName</th>
  <th style="text-align: right;">address</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td style="text-align: left;">Lily</td>
  <td style="text-align: center;">Sam</td>
  <td style="text-align: right;">someaddress</td>
  </tr>
  <tr>
  <td style="text-align: left;">Sam</td>
  <td style="text-align: center;">Adams</td>
  <td style="text-align: right;">anotheraddress</td>
  </tr>
  <tr>
  <td style="text-align: left;">Michael</td>
  <td style="text-align: center;">Stevens</td>
  <td style="text-align: right;">SamsoniteStreet</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>Sort preference should follow the order from higher to lower
  firstName &gt; lastName &gt; address (firstName has the highest preference and address has the lowest)</p>
  <p>So If I search &quot;Sam&quot;, results should be returned sorted in this order:</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th style="text-align: left;">firstName</th>
  <th style="text-align: center;">lastName</th>
  <th style="text-align: right;">address</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td style="text-align: left;"><strong>Sam</strong></td>
  <td style="text-align: center;">Adams</td>
  <td style="text-align: right;">anotheraddress</td>
  </tr>
  <tr>
  <td style="text-align: left;">Lily</td>
  <td style="text-align: center;"><strong>Sam</strong></td>
  <td style="text-align: right;">someaddress</td>
  </tr>
  <tr>
  <td style="text-align: left;">Michael</td>
  <td style="text-align: center;">Stevens</td>
  <td style="text-align: right;"><strong>Sam</strong>soniteStreet</td>
  </tr>
  </tbody>
  </table>
  </div>