title: Move up/down a model in a backbone collection
body: <p>I am trying to change the order of models in my backbone collection on a click of button.</p>
  
  <p>I am doing this in my code: </p>
  
  <pre><code>collectionForJsonElement= Backbone.Collection.extend({
              //set model for collection
              model: modelForJsonElement,
              //set filterBy function to Collection
              filterBy: function(searchTerm) {
                  filtered= this.filter(function(model) {
                      return ((model.get('text').toString()).indexOf(searchTerm.toString()) !== -1);
                  });
                  return new collectionForJsonElement(filtered);
              },
              //set moveUp function to Collection
              moveUp: function(model) { // I see move up as the -1
                  var index = this.indexOf(model);
                  if (index &gt; 0) {
                      this.remove(model, {silent: true}); // silence this to stop excess event triggers
                      this.add(model, {at: index-1});
                  }
              },
              //set moveDown function to COllection
              moveDown: function(model) { // I see move up as the -1              
                  var index = this.indexOf(model);
                  if (index &lt; this.models.length) {
                      this.remove(model, {silent: true});
                      this.add(model, {at: index});
                  }
              }
          });
  </code></pre>
  
  <p>When I am trying to move up, it is working fine. My model index position is changing by -1. However when i am trying to move down, My model goes to the last position.</p>
  
  <p>For ex, in my backbone collection, i have 3 model </p>
  
  <pre><code>One
  Two
  Three
  </code></pre>
  
  <p>If i select three, and click on move up button, new order for model in collection is changed to:</p>
  
  <pre><code>One
  Three
  Two
  </code></pre>
  
  <p>However if i select one, and click move down button, new order for model is changed to:</p>
  
  <pre><code>Three
  Two
  One
  </code></pre>
  
  <p>I cant figure out why it is not working right in move down case.
  Can someone give me insight what wrong is going here?</p>