title: AngularJS - Sorting data ascending / descending when column is clicked
body: <p>I have the following view code:</p>
  
  <pre><code>&lt;tr ng-repeat="c in clients | orderBy:'code'"&gt;
      &lt;td&gt;{{c.firstname}} {{c.lastname}}&lt;/td&gt;
      &lt;td&gt;{{c.telephone}}&lt;/td&gt;
      &lt;td&gt;{{c.location}}&lt;/td&gt;
      &lt;td&gt;{{c.code}}&lt;/td&gt;
  &lt;/tr&gt;
  </code></pre>
  
  <p>I want to change the <code>orderBy:'code'</code> when column is clicked, assume that the user clicked on the column location, i want the <code>orderBy</code> condition to change to 'location' instead of code, and to be in this form </p>
  
  <pre><code>&lt;tr ng-repeat="c in clients | orderBy:'location'"&gt;
  </code></pre>