This is an interview question.
There are some random numbers given (let’s say in an integer array).
- How can we sort all the even numbers in ascending order first and then sort all the odd numbers in descending order.
- which Collection suits best.
Input numbers:
12 67 1 34 9 78 6 31
Output saved in Collection:
6 12 34 78 67 31 9 1
Any collection that supports sorting with a custom comparer will do – even an array. Implement your custom comparator as follows: