import Backbone from 'backbone';
import Device from './Device';

export default Backbone.Collection.extend({
  model: Device,

  comparator: (left, right) => {
    const max = Number.MAX_VALUE;
    return (right.get('priority') || max) - (left.get('priority') || max);
  },

  getSorted() {
    return this.sort();
  }
});

import { Collection } from 'backbone';
import Device from './Device';

export default class Devices extends Collection {
  comparator(left, right) {
    const max = Number.MAX_VALUE;
    return (right.get('priority') || max) - (left.get('priority') || max);
  }

  getSorted() {
    return this.sort();
  }
}

Devices.prototype.model = Device;

Update devices collection