array.sort() in javascript modifies the underlying array:
> a = [5,1,3]
[ 5, 1, 3 ]
> a.sort()
[ 1, 3, 5 ]
> a
[ 1, 3, 5 ]
>
Is there anyway to sort the array not in place, so that the sorted version is returned as a copy. like this?
> a = [5,1,3]
[ 5, 1, 3 ]
> b = a.some_function()
[ 1, 3, 5 ]
> a
[ 5, 1, 3 ]
> b
[ 1, 3, 5 ]