From 094377c8aea7591b62bf8c55331bf2788ba8e3e5 Mon Sep 17 00:00:00 2001 From: Shahbaz Tariq Date: Wed, 4 Apr 2018 10:58:09 +0100 Subject: [PATCH 1/2] No need to sort arrays that are 0 or 1 in length. --- index.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/index.js b/index.js index 01880e1..a903dce 100644 --- a/index.js +++ b/index.js @@ -29,6 +29,10 @@ function arraySort(arr, props, opts) { if (!Array.isArray(arr)) { throw new TypeError('array-sort expects an array.'); } + + if (arr.length < 2 { + return arr; + } if (arguments.length === 1) { return arr.sort(); From 426c17b3cbce9850bb783f55bfac8f9d3b999155 Mon Sep 17 00:00:00 2001 From: Shahbaz Tariq Date: Wed, 4 Apr 2018 11:06:32 +0100 Subject: [PATCH 2/2] Corrected typo. --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index a903dce..293766e 100644 --- a/index.js +++ b/index.js @@ -30,7 +30,7 @@ function arraySort(arr, props, opts) { throw new TypeError('array-sort expects an array.'); } - if (arr.length < 2 { + if (arr.length < 2) { return arr; }