title: Backbone.js: correct way of filtering a collection?
body: <p>The current method I'm using is to filter a collection, which returns an array, and use</p>
  
  <pre><code>collection.reset(array)
  </code></pre>
  
  <p>to re-populate it. However, this modifies the original collection, so I added an array called "originalCollectionArray" which keeps track of the initial array state of the collection. When no filtering is active I simply use</p>
  
  <pre><code>collection.reset(originalCollectionArray)
  </code></pre>
  
  <p>But then, I need to keep track of adding and removing models from the real collection, so I did this:</p>
  
  <pre><code>// inside collection
  initialize: function(params){
      this.originalCollectionArray = params;
      this.on('add', this.addInOriginal, this);
      this.on('remove', this.removeInOriginal, this);
  },
  addInOriginal: function(model){
      this.originalCollectionArray.push(model.attributes);
  },
  removeInOriginal: function(model){
      this.originalTasks = _(this.originalTasks).reject(function(val){
          return val.id == model.get('id');
      });
  },
  filterBy: function(params){
      this.reset(this.originalCollectionArray, {silent: true});
      var filteredColl = this.filter(function(item){
          // filter code...
      });
      this.reset(filteredColl);
  }
  </code></pre>
  
  <p>This is quickly becoming cumbersome as I try to implement other tricks related to the manipulation of the collection, such as sorting. And frankly, my code looks a bit hacky. Is there an elegant way of doing this?</p>
  
  <p>Thanks</p>