Given a linked list, sort it using insertion sort.
Linked list: 1 → 6 → 2 → 4 → 3 → 5 → 2 → 8 → 4 → 7
Result: 1 → 2 → 2 → 3 → 4 → 4 → 5 → 6 → 7 → 8
The first line contains an integer ‘T’ denoting the number of independent test cases.
For each test case the input has two lines:
For each test case, a line containing ‘n’ space-separated integers denoting the resultant linked list elements.
2
10
1 6 2 4 3 5 2 8 4 7
10
1 2 2 3 4 4 5 6 7 8
1 2 2 3 4 4 5 6 7 8
1 2 2 3 4 4 5 6 7 8
1 <= T <= 100
1 <= n <= 500
1 <= element <= 500