Skip to content

Commit

Permalink
return a sorted copy from array.sort
Browse files Browse the repository at this point in the history
Current behavior is to sort the original source array

Fixes #249
  • Loading branch information
gabrielgrant authored and Kelly Selden committed Feb 26, 2017
1 parent bbe0a2d commit 109b091
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions addon/array/sort.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -38,7 +38,7 @@ export default function(array, sortDefinition) {
};
}

return array.sort(sortCallback);
return array.slice().sort(sortCallback);
};
}

Expand Down

0 comments on commit 109b091

Please sign in to comment.