how do I convert object properties of type String to int sorting?
attribute area_size
is a String type attribute, but the values are all numeric types. I want to sort it first by Id, and then by the size of area_size. Here"s my code:
defectFS.stream()
.sorted(Comparator.comparing(WppDefectF::getId)
.thenComparing((d1,d2) ->
Integer.compare(Integer.parseInt(d1.getArea_size()), Integer.parseInt(d1.getArea_size()))
);
when I use the above code to implement it, I find that the values of D1 and D2 are always the same, so the order is out of order. How to sort the String attributes of lambda expressions in java8?