This is more a comment than a question.
Academic Question: How do I check if a shorted array is 'different' than its unsorted version?
(...or, is this the standard Sort behavior for an array?)
It appears that the current Array.sort() mutates itself, even though it's technically immutable via the 'let'. That is, a CONSTANT array's contents is mutable as long as the array's length isn't changed.
The following code snippet demonstrates the situation:
let a = [5,4,3,2,1]
let a2 = [5,4,3,2,1]
(a == a2) // *true*
(a === a2) // *false*
let b = sort(a)
a // [1,2,3,4,5]
b // [1,2,3,4,5]
(a == b) // *true*
(a === b) // *true*
I can understand that (a === a2) is false; being that they're two distinct arrays.
But how can I tell the difference between two arrays, array #1 and it's sorted version?
It appears the sorting an array merely mutates itself; and hence I would have to make a copy and then, use the '==' to check the difference.