

For a node, if there is no higher value node in the linked list, it’s ‘nextHigher’ pointer should point to NULL.
The first line of input contains an integer 'T', the number of test cases to run.
The first and the only line of every test case contains the elements of the singly linked list separated by a single space and terminated by -1. Hence, -1 would never be a list element.
For every test case, print the elements of the modified linked list in ascending order. The elements should be single-space separated, terminated by -1.
The output of each test case is printed in a separate line.
You do not need to print anything, It already has been taken care of. Just implement the function and return the pointer to the minimum node in the modified linked list.
The linked list will be traversed using the ‘nextHigher’ pointer to produce the output.
1 <= T <= 10
1 <= N <= 10^4
-10^3 <= data <= 10^3 and data != -1
Where ‘data’ denotes the value of the nodes in the linked list.
The idea is very simple. We will consider every node and check all the remaining nodes. If we encounter a node with just greater value than the current node, we will simply connect the ‘NEXT_HIGHER’ pointer of the current node to that node.
If we analyse, we can see that the modified linked list printed is sorted in ascending order. This is because every node’s ‘NEXT_HIGHER' pointer is pointing to the next greater valued node.
Thus, the idea is to sort the linked list formed by ‘NEXT_HIGHER' pointer.
Algorithm:
Algorithm for Merge Sort:
Merge Sort is a divide and conquer algorithm. In this algorithm, we divide the list into two parts, recursively sort the two parts and finally merge them such that the resultant list will be sorted.
In the end, if any of the sublists becomes empty and the other sublist is non-empty, then we will add all nodes of the non-empty sublist in the ‘MERGE_LIST’.