Skip to content

Tag: comparator

Can’t pass wildcard Comparator to function

I have the following sort method in a clone of ArrayList: The sorter object is an instance of Sort: I get the following error on the sorter.mergeSort line: I’m not sure why this is happening as both the parameter and argument have type Comparator<? super E>. Answer Thanks to everyone for their com…

Sort character array using java comparator

Sort a character array lexicographically with an additional condition that all c’s comes before all b’s. This could be done manually but I want to code it via inbuilt sorting using comparators. The code I wrote – Gives output: [a, a, a, a, a, b, c, b, d, r, r]. The c only comes before one of…

arranging the records in customised way

Sort Procedure First sort by the delivered date & in case of multiple records on same date sort by delivered time (Note: if a record has both ordered and Delivered Date ,it should be sorted by Delivered date only) 08-JUN: 03.00, 08-JUN: 04.00 Then look at the ordered date without delivered date which also…