From 619ac6974625f942d86b7c69583552b282db432a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Lipi=C5=84ski?= Date: Thu, 17 Oct 2019 11:23:07 +0200 Subject: [PATCH] Ensure `orderBy` will accept iteratee path arrays #4438 (#4513) --- .internal/baseOrderBy.js | 2 +- test/orderBy.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.internal/baseOrderBy.js b/.internal/baseOrderBy.js index aab783b9c9..439e06b307 100644 --- a/.internal/baseOrderBy.js +++ b/.internal/baseOrderBy.js @@ -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 diff --git a/test/orderBy.js b/test/orderBy.js index 22aa4755c4..7aba5fe48d 100644 --- a/test/orderBy.js +++ b/test/orderBy.js @@ -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() {