jeudi 9 juillet 2015

When using the Ember sortBy method with multiple arguments how do i reverse one argument and not the other?

Lets say I have a route such as

/routes/pets.js

export default Ember.Route.extend({
  model: function() {
    return this.store.findAll('pet').then(function(pets) {
      return pets.sortBy('name', 'ownerName');
    });
  }
});

Which will sort by name and then orderName. But what if I wanted to sort by one property ascending and one descending?

It is easy enough to do one descending, like so:

return pets.sortBy('name').reverse();

But I can't see how to do with with 2 or more arguments?

Aucun commentaire:

Enregistrer un commentaire