Home > other >  Sorting issue for Decimal128 | no instance(s) of type variable(s) U exist so that Decimal128 conform
Sorting issue for Decimal128 | no instance(s) of type variable(s) U exist so that Decimal128 conform

Time:08-31

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 :

enter image description here

Kindly suggest if there is a workaround for this.

CodePudding user response:

Change

Comparator.comparing(OdsALSAccBalHistory::getSrtCdeAccNum)

to

Comparator.comparing((OdsALSAccBalHistory ods) -> ods.getSrtCdeAccNum().bigDecimalValue​())
  • Related