title: Filter and sort backbone collection with array of ids
body: <p>I'm quite new to Backbone so I am getting into some problems I can't quite figure out.</p>
  
  <p>I have a Backbone collection with a bit over 100 items. I want to filter these with an array of ids, that is working fine, but I want the order of the items also based on this array's order of items. That is not working. The other sorting methods seems to be asciibetical based, that's not what I need either. Is it possible to get items using this filter, and then also put them into the collection in the order I've defined?</p>
  
  <p>I have an array of id's that I filter with, this array looks like this:</p>
  
  <pre><code>var dDefaultItems = ['1','2','146','3','4','9','26','8','96','10','11','54','145','273','38'];
  </code></pre>
  
  <p>The code for the collection and filtering looks like this:</p>
  
  <pre><code>var ChannelCollection = Backbone.Collection.extend({        
      fetch : function() {
         var params = _.extend({}, arguments, { 
              data : { 
                  "groupnumber" : "1000"
              }
          });
          this.constructor.__super__.fetch.apply(this, [params]);
  
      },
  
      model : Channel,
  
      url : function () {
          return utility.apiUrl('/myurl/tothething');  
      },
  
      filterData: function(params) {
  
          this.originalModels = this.models.slice();
  
          _.each(params, function(val, key){
              if (typeof val !== 'object') val = [ val ];
              this.models = _.filter(this.models, function(model){
                  return _.indexOf(val, model.get(key)) !== -1;
              }, this);
          }, this);
          return this.reset(this.models).toJSON();
      },
  
      parse : function(json) {            
  
          return json.channelInfoList;
      }
  
   });
  </code></pre>
  
  <p>Then I render this in a view with this code (there's other bits of code for defining model and other attributes that I don't think is relevant, I may be wrong, but I'm thinking someone will know what I need from looking at this.)</p>
  
  <pre><code>var ChannelListView = Backbone.View.extend({
  
      initialize: function() {
         var _this = this;
  
          currentChannelList = new ChannelCollection();
  
          currentChannelList.once("sync", function() {
             _this.render();
          });
  
          currentChannelList.fetch();
      },
      render : function() {
        var _this = this;
  
        $(_this.el).empty();
  
       dust.render("list-channels", { channelList : currentChannelList.filterData({id: dDefaultItems})} , function(err, html) {
  
          var $el = $(html).appendTo($(_this.el));
        });  
      }
   });   
  </code></pre>