Given a linked list of size N consisting of 0s, 1s and 2s. The task os to sort this linked list such that all zeroes segregate to headside, 2s at the end and 1s in the mid of 0s and 2s.
First line of input contains number of testcases T. For each testcase, first line of input contains length of linked list and next line contains N elements as the data in the linked list.
For each testcase, segregate the 0s, 1s and 2s and display the linked list.
1 <= T <= 100
1 <= N <= 103
The task is to complete the function sortList() which takes head reference as the argument and returns void.
1 2 2 1 2 0 2 2
0 1 1 2 2 2 2 2
Testcase 1: All the 0s are segregated to left end of the linked list, 2s to the right end of the list and 1s in between.