I have list of object type of EventCustomDTO. In this DTO there are many field is there. I want to sort based on there value.
I want sort list based on this three field value. 1.passport = true, 2.featured=true, and status of cancel and Unconfirmed are added into last of list.
@ToString
@AllArgsConstructor
@NoArgsConstructor
@Data
public class EventCustomDTO {
private Long id;
private String eventName;
private Boolean passport;
private Boolean featured;
private String status;
}
1.I have try below code
Lisi<EventCustomDTO> list = eventRepo.getAllEvents();
list.sort(Comparator.comparing(EventCustomDTO::getPassport).reversed()
.thenComparing(EventCustomDTO::getFeatured)
.thenComparing(EventCustomDTO::getEventStatus));
but it is not working as per my requirement. So anyone have idea about it. How to sort list of data based on property value.