Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

sort array without changing the original js

// You need to copy the array before you sort it.
// One way with es6:
const sorted = [...arr].sort();

// or use slice() without arguments
const sorted = arr.slice().sort();
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #sort #array #changing #original #js
ADD COMMENT
Topic
Name
7+2 =