Comparator sort matching String at first, and rest using default sorting order
问题 String currency = EUR; List<Payment> payments = #has payments, with one field being Currency; //This is not it: payments.sort(Comparator.comparing(o -> o.getCurrency().equals(currency)); I want all the payments which currency equals to variable currency in my case EUR to be at the top of the list, others order stays the same. And if there is nothing that equals with the variable currency then sort by default value which for example is USD. I know this can be done other ways, but this is kind