var AmpersandCollection = require('ampersand-collection');

var Metadata = AmpersandCollection.extend({
  mainIndex: 'id',
  comparator: function (a,b) {
    return b.power - a.power;
  }
});

/*
  Convenience method to see if each item
  exists in the collection and to remove
  it and add the new one if it does
*/
Metadata.prototype.replace = function (data) {
  if (data.forEach) {
    data.forEach(this.replace.bind(this));
  } else {
    if ( this.get(data.id) ) {
      this.remove(data, { silent: true });
    }
    this.add(data);
  }
}

module.exports = Metadata;
@@ -164,23 +164,21 @@
 n b.
-power - a.power
+time - a.time
 ;%0A  

order by time