From fc9ce65515ef81b8d9982de72b7ab9070ac92176 Mon Sep 17 00:00:00 2001 From: Gabriel Grant Date: Thu, 23 Feb 2017 00:28:12 -0800 Subject: [PATCH] return a sorted copy from array.sort Current behavior is to sort the original source array Fixes #249 --- addon/array/sort.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addon/array/sort.js b/addon/array/sort.js index f9e190a..56eaa2b 100644 --- a/addon/array/sort.js +++ b/addon/array/sort.js @@ -8,7 +8,7 @@ export default function(array, sortDefinition) { let computedCallback; if (sortDefinition === undefined) { - computedCallback = array => array.sort(); + computedCallback = array => array.slice().sort(); } else { computedCallback = function(array, sortDefinition) { let sortCallback; @@ -38,7 +38,7 @@ export default function(array, sortDefinition) { }; } - return array.sort(sortCallback); + return array.slice().sort(sortCallback); }; }