lodash sortBy then groupBy, is order maintained?
I'm having trouble figuring out from the lodash documentation if my assumption about sorting and grouping is correct. If I use sortBy, then use groupBy, do the arrays produced by groupBy maintain the sort order of items? For example, say I have the following array: var testArray = [[5,6],[1,3],[5,4],[5,1]] And I would like to group these by their first element, but also have them sorted by their second element within these groups. So, in lodash I assume I can do the following: _.chain(testArray) .sortBy(function (item) { return item[1]; }) .groupBy(function (item) { return item[0]; }) .value()