title: IndexedDB search for key and sort
body: <p>At the moment i have 2 functions. One for querying the DB for results with a specific key/value pair and one for getAll rows sorted by a specific key.
  Is there a way combine these two ? So i want to have a function where you search a store for objects where a=1 sorted by b asc . </p>
  
  <p>Function to get results by index:</p>
  
  <pre><code>getByIndex : function(store,indexKey,indexValue,callback){
      var results = [];
      this._initTransaction(store,"readonly",function(err,transaction){
  
          var index = transaction.objectStore(store).index(indexKey);
          index.openCursor(IDBKeyRange.only(indexValue)).onsuccess = function(event) {
            var cursor = event.target.result;
            if (cursor) {
              results.push(cursor.value);
              cursor.continue();
            } else {
              callback(true,results);
            }
          };
      })  
  }
  </code></pre>
  
  <p>Function to get results sorted by key:</p>
  
  <pre><code>getSorted : function(store,sortKey,callback){
      var results = [];
      this._initTransaction(store,"readonly",function(err,transaction){
  
          var index = transaction.objectStore(store).index(sortKey);
          index.openCursor(null,'next').onsuccess = function(event) {
              var cursor = event.target.result;
            if (cursor) {
              results.push(cursor.value);
              cursor.continue();
            } else {
              callback(true,results);
            }
          };
      })      
  },
  </code></pre>
  
  <p>Thanks for your help !</p>