Array.prototype.toSortedintermediateconst arr = [3, 1, 2]
arr.sort((a,b)=>a-b) // mutates arr β [1, 2, 3]
const s = [3,1,2].toSorted((a,b)=>a-b) // safe copyChoose toSorted() over sort() when working in functional or immutable patterns.
Unlike sort, which sorts in place and returns the same reference, toSorted always returns a new array β the result is never === the input.
Implement toSortedReturnsNew which returns true if arr.toSorted() is a different reference than arr.