Ad
  • Default User Avatar
  • Default User Avatar

    Correct me if I am wrong but the sort method sorts the original array in place. The other methods do not mutate our array. So if we were to run the function multiple times on the same array, it will return the same result. We could then say that the function is pure. However, the original array has been mutated in ascending order. If other function manipulate that set of numbers relying on indexing, it could have side effects. So maybe not best practice. Here, creating a copy of the array before sorting could have avoided that issue.