I have a list of users (more precisely, six) in the collection with the properties "firstname", "lastname". Performing the selection, the comparator below sorts them by "first", and it works fine.
comparator : function (user) { return user.get("firstname").toLowerCase(); }
But if I try to sort the collection later, with a different value, that is, "lastname", this will not work. The order remains the same.
this.collection.sortBy(function(user) { return user.get("lastname").toLowerCase(); });
What am I doing wrong?
Update
This way, the data returned from sortBy IS is sorted, but that does not help me, since my view is related to the collection. If I reset the collection and add the sorted array back to the collection, the comparator will do this and sort it in the "firstname" order.
var sorted = this.collection.sortBy(function(user) { return user.get("lastname").toLowerCase(); });
screenm0nkey
source share