My code is not passing one test case

It seems your approach is wrong. Consider any other test case with 6 or 8 numbers. You code is giving wrong answer.
say if input:
8
1 3 2 2 3 1 4 5
Expected Output:
4 5
Your Output:
2 2 3 3 4 5
Also you have to do this question in Linear time but you are doing sorting.
Follow the approach as taught in the course:
Step 1: XOR all the numbers. You will be left over with the XOR result of the two unique numbers.
Step 2: Find the position of the rightmost set bit of the result. Say it is i.
Step 3: Pair the given numbers according to the set bits at ith position.(XOR all the numbers whose i’th bit is set) This will give you one unique number.
Step 4: XOR the result of Step 1 with Step 3 and you will get the second unique number.

Say the the numbers are : 2 1 3 5 1 6 3 2
Step 1: Will give the XOR result of 5 and 6 ie 5^6 . It will be 101 ^ 110 = 011
Step 2: So the rightmost set bit of result is at i=0 from left.
Step 3: So pair all the numbers whose last or 0th bit is set.So result will be 1^3^5^1^3= 5 So 5 is one unique number.
Step 4: (Step 1)^(Step 3)= 5^6^5=6 which is the second unique number.

Hope this helps.