Problem in Even After Odd Challenge

The link to my submission is - https://ide.codingblocks.com/s/358775 . I am getting 1 test case wrong. I have used an approach similar to mergesort. The problem is that in my output, all even occur after odd only but the order of even nodes is reversed i.e. not in the same order as in case of input. Please help.

put all even numbers in a list and all odd numbers in separate list and then add head of even list to the tail of odd list and return head of odd list