Java stream sort 2 variables ascending/desending
问题 I want to sort seq1 ascending and seq2 descending so I do this: list = list.stream().sorted(comparing(AClass::getSeq1).thenComparing( AClass::getSeq2).reversed()).collect(toList()); But the result come out as both seq1 and seq2 are sorted in descending order. I can do this to make seq1 ascending and seq2 descending: sorted(comparing(AClass::getSeq1) .reversed().thenComparing(AClass::getSeq2).reversed() What is really the correct way to do this? 回答1: In your first example, reversed is applied