Issue
I was trying to sort a list according to a field which is Decimal 128 but getting "no instance(s) of type variable(s) U exist so that Decimal128 conforms to Comparable<? super U> " error.
odsALSAccBalHistoryListFinal =
alsBHSortLevel1
.stream()
.sorted(
Comparator.comparing(OdsALSAccBalHistory::getSrtCdeAccNum)
.thenComparing(OdsALSAccBalHistory::getYrMo, Comparator.reverseOrder()))
.collect(Collectors.toList());`
Data Type :
Kindly suggest if there is a workaround for this.
Solution
Change
Comparator.comparing(OdsALSAccBalHistory::getSrtCdeAccNum)
to
Comparator.comparing((OdsALSAccBalHistory ods) -> ods.getSrtCdeAccNum().bigDecimalValue())
Answered By - Eritrean
Answer Checked By - Terry (JavaFixing Volunteer)