title: AngularJS custom order by with function
body: <p>How can I get the value of a input text and compare with a value of an object with an array?</p>
  
  <p>When I type the property name of the comments array, has to order by this text that was typed.</p>
  
  <p>For example type author order by author.
  I search about this, read documentation but I didn't find a solution.
  Can i pass a function in the order by? I try but didn't work.</p>
  
  <p>I found too many example passing just one value or without the input text and I wanna pass 3 options to order, if author, rating or date, but if someone type this words in the input text.</p>
  
  <p>Why doesn't work like this:</p>
  
  <pre><code>Sort by: &lt;input type="text"  ng-model="**sortBy**"&gt;
                     &lt;div ng-repeat="dishcomment in dishCtrl.dish.comments|filter:**sortBy**"&gt;
  </code></pre>
  
  <hr>
  
  <pre><code> var dish={
       name:'Uthapizza',
       image: 'images/uthapizza.png',
       category: 'mains', 
       label:'Hot',
       price:'4.99',
       description:'A unique combination of Indian Uthappam (pancake) and Italian pizza, topped with Cerignola olives, ripe vine cherry tomatoes, Vidalia onion, Guntur chillies and Buffalo Paneer.',
       comments: [
           {
               rating:5,
               comment:"Imagine all the eatables, living in conFusion!",
               author:"John Lemon",
               date:"2012-10-16T17:57:28.556094Z"
           },
           {
               rating:4,
               comment:"Sends anyone to heaven, I wish I could get my mother-in-law to eat it!",
               author:"Paul McVites",
               date:"2014-09-05T17:57:28.556094Z"
           },
           {
               rating:3,
               comment:"Eat it, just eat it!",
               author:"Michael Jaikishan",
               date:"2015-02-13T17:57:28.556094Z"
           },
           {
               rating:4,
               comment:"Ultimate, Reaching for the stars!",
               author:"Ringo Starry",
               date:"2013-12-02T17:57:28.556094Z"
           },
           {
               rating:2,
               comment:"It's your birthday, we're gonna party!",
               author:"25 Cent",
               date:"2011-12-02T17:57:28.556094Z"
           }
       ]
   };
  
   this.dish = dish;
  </code></pre>
  
  
  
  <pre><code>Sort by: &lt;input type="text"  ng-model="searchBox"&gt;
             &lt;div ng-repeat="dishcomment in dishCtrl.dish.comments | orderBy:searchBox track by $index"&gt;
               &lt;blockquote&gt; 
                  &lt;p&gt;{{dishcomment.rating}} Stars&lt;/p&gt;
                  &lt;p&gt;{{dishcomment.comment}}&lt;/p&gt;
                  &lt;small&gt;{{dishcomment.author}}
                  {{dishcomment.date | date:'MMM.dd, yyyy'}}&lt;/small&gt; 
               &lt;/blockquote&gt;
  </code></pre>