Java8 scheduling problem

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?

Mar.21,2021

(d1,d2) -> Integer.compare(Integer.parseInt(d1.getArea_size()), Integer.parseInt(d1.getArea_size()))

there is a problem in this place. It says d1.getArea_size () in both places.

< hr >

and your writing is complicated, you can go like this:

Comparator.comparing(WppDefectF::getId).thenComparing(defectF -> Integer.parseInt(defectF.getArea_size()))

that is, first sort by id, and then sort by int form of area_size.


take a look at this article the sorting method of JDK8

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e3f892-4356e.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e3f892-4356e.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?