title: Sort array on nested key
body: <p>I am using this function to sort an array based on object key:</p>
  
  <pre><code>function keysrt(arr, key, reverse) {
      var sortOrder = 1;
      if(reverse){
          sortOrder = -1;
      }
      return arr.sort(function(a, b) {
          var x = a[key],
              y = b[key];
  
          return sortOrder * ((x &lt; y) ? -1 : ((x &gt; y) ? 1 : 0));
      });
  }   
  </code></pre>
  
  <p>It works well with this type of array, where key is on the first level:</p>
  
  <pre><code>var a = [ 
      { id: 0, last: 'Anne'},
      { id: 1, last: 'Odine'},
      { id: 2, last: 'Caroline'}
  ]
  
  keysrt(a, 'last');
  </code></pre>
  
  <p>How can I make it work with this example, where title key is <em>nested</em>? </p>
  
  <pre><code>var b = [ 
      { id: 0, last: 'Anne',     data:{title: 'habc'}},
      { id: 1, last: 'Odine',    data:{title: 'asdf'}},
      { id: 2, last: 'Prentice', data:{title: 'tzuio'}}
  ]
  
  keysrt(b, 'title');
  </code></pre>