Sorts a typed array numerically in place and returns a reference to the same typed array.
sort(compareFn?)
compareFn optional function(a, b)
Function used to determine the order of the elements. It should return a negative value if the first argument is less than the second argument, zero if they are equal, and a positive value otherwise.
If omitted, the elements are sorted numerically in ascending order.
new BigInt64Array([11,2,22,1]).sort()
BigInt64Array [1, 2, 11, 22]
var original = new BigInt64Array([11,2,22,1])
var sorted = original.sort()
print(original)
print(sorted)
print(original === sorted)
1,2,11,22
1,2,11,22
true
// use slice() to avoid mutating the original array:
var original = new BigInt64Array([11,2,22,1])
var sorted = original.slice().sort()
print(original)
print(sorted)
print(original === sorted)
11,2,22,1
1,2,11,22
false