Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

return new array on sort 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: #return #array #sort #js
ADD COMMENT
Topic
Name
8+1 =