in reply to Check if sort has changed order
Why don't you test if the array needs sorting first? This probably takes as much time as comparing the result to the original. And you might save the sorting if not needed.