How can I use lodash/underscore to sort by multiple nested fields?

Update: See the comments below, this is not a good solution in most cases.


Someone kindly answered in the issue I created. Here’s his answer, inlined:

_.sortBy(data, function(item) {
   return [item.sortData.a, item.sortData.b];
});

I didn’t realize that you’re allowed to return an array from that function. The documentation doesn’t mention that.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)