Why does Collections.sort() creates an extra object array and performs Tim sort on the array and then finally copies the sorted array back into List object? I know this call is optimized for LinkedList, but won't we lose out on performance for ArrayList?
We could have avoided 2n number of operations in converting it into an object array and adding them back to the list. I know that these extra operations wouldn't affect the Big-O of the whole sorting operation, but I believe it could've been further optimised for ArrayList.
Am I missing something here? I'm just trying to understand why the architecture is laid out as such. Thanks.