You are given the head of Doubly Linked List containing ‘N’ nodes. Each node will have an integer value stored in it. You need to return the head of the Doubly linked list after sorting it using the QuickSort algorithm.
For example :

The first line of the input contains an integer ‘T’ denoting the number of test cases.
The first line of each test case contains a single positive integer ‘N’ denoting the number of the element nodes present in the doubly linked list.
The second line of each test case contains ‘N’ space-separated integers denoting the elements of the doubly linked list.
Output Format :
The only line of output of each test case should contain ‘N’ space-separated integer in the sorted order.
Note :
You do not need to print anything, it has already been taken care of. Just implement the given function.
1 <= T <= 50
1 <= N <= 500
-10 ^ 9 <= A[i] <= 10 ^ 9
Where ‘A[i]’ is the value of 'ith' node.
Time Limit: 1 sec
2
4
4 2 -3 4
5
3 3 4 2 4
-3 2 4 4
2 3 3 4 4
Test case 1 :
After sorting the list [4,2,-3,4] will look like [-3,2,4,4].
Test case 2 :
After sorting the list [4,2,-3,4] will look like [-3,2,4,4].
2
5
45 -2 42 5 -11
6
-2 12 -1 1 20 1
-11 -2 5 42 45
-2 -1 1 1 12 20
Instead of swapping nodes, you can swap values present in the node.
O(N^2), where ‘N’ is the number of nodes present in the array.
In each recursive call, we do O(N) operations. And in the worst case, we may have ‘N’ recursive calls in the stack which will make the time complexity to be O(N^2).
O(N), where ‘N’ is the number of nodes present in the array.
In the worst case, the recursive function stack can contain ‘N’ entries.