You are doing the right thing by deep copying the arrays. As the docs for the function say, it sorts the values and keys, so to prevent modification of the input, you indeed need to operate on a copy.
You are doing the right thing by deep copying the arrays. As the docs for the function say, it sorts the values and keys, so to prevent modification of the input, you indeed need to operate on a copy.