title: Grails - sorting list of entities on gsp using sortableColumn
body: <p>I have the following entity:</p>
  
  <pre><code>class User {
  
      String name
      String contactName
      String primaryEmail
      String url
      String phoneNumber
      String address
      //..
  }
  </code></pre>
  
  <p>I have gsp that display list of all users and I want to be able to sort users by contactName, name and phoneNumber, in the controller I have list() method that just returns list of all users:</p>
  
  <pre><code>class UserController {
       ...
  
      def list() {
          [users: User.all]
      }
  }
  </code></pre>
  
  <p>My gsp is like this:</p>
  
  <pre><code>&lt;body&gt;
  &lt;table&gt;
      &lt;thead&gt;
      &lt;tr&gt;
          &lt;g:sortableColumn property="contactName" title="Bookmaker"/&gt;
          &lt;g:sortableColumn property="name" title="Name"/&gt;
          &lt;g:sortableColumn property="phoneNumber" title="Phone"/&gt;
      &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
      &lt;g:each in="${users}" status="i" var="user"&gt;
          &lt;tr&gt;
              &lt;td&gt;${user.contactName}&lt;/td&gt;
              &lt;td&gt;${user.name}&lt;/td&gt;
              &lt;td&gt;${user.phoneNumber}&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/g:each&gt;
      &lt;/tbody&gt;
  &lt;/table&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p>But when I click on one of the sortable columns request is sent (something like this: "list?sort=phoneNumber&amp;order=asc") but response is always the same. Now it seems to me like code that actually sorts the list should be implemented by myself. Or am I doing something wrong? Thanks!</p>