Skip to content

Commit

Permalink
Ensure orderBy will accept iteratee path arrays lodash#4438 (lodash…
Browse files Browse the repository at this point in the history
  • Loading branch information
falsyvalues committed Oct 17, 2019
1 parent 23b2a33 commit 619ac69
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .internal/baseOrderBy.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function baseOrderBy(collection, iteratees, orders) {
if (iteratees.length) {
iteratees = iteratees.map((iteratee) => {
if (Array.isArray(iteratee)) {
return (value) => baseGet(value, iteratee)
return (value) => baseGet(value, iteratee.length === 1 ? iteratee[0] : iteratee)
}

return iteratee
Expand Down
4 changes: 2 additions & 2 deletions test/orderBy.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ describe('orderBy', function() {
it('should sort by nested key in array format', () => {
var actual = orderBy(
nestedObj,
[['address','zipCode'], ['address.streetName']],
[['address', 'zipCode'], ['address.streetName']],
['asc', 'desc'],
);
assert.deepStrictEqual(actual, [nestedObj[2], nestedObj[3], nestedObj[0], nestedObj[1]], nestedObj[4]);
assert.deepStrictEqual(actual, [nestedObj[2], nestedObj[3], nestedObj[1], nestedObj[0], nestedObj[4]]);
});

it('should sort by multiple properties by specified orders', function() {
Expand Down

0 comments on commit 619ac69

Please sign in to comment.