Test case #1 failing

you are also sorting the even and odd numbers your dont need to do that
For example in case
7
1 2 4 3 8 5 6

Correct answer: 1 3 5 2 4 8 6 Your answer: 1 3 5 2 4 6 8

all you need to do is make 2 different lists for odd and even if the number is odd push it into odd list else push it into even list and then print odd list followed by even list

Yes, I understand that approach. But wanted to try it out using a comparator.
I tried out multiple things, but could keep the order of the odd and even the same. Do you have any idea about doing it that way?

using the comparator wont work because it will change the order.

right I figured it would work that way after trying multiple if-else combinations.

Thanks for your help.