How does Java 8 Stream: sort by an attribute under a sub-object in an object?

I have an object List, such as List < Main >, a property in Main is a Sub object, and an attribute id in Sub.
I want to sort by Main.Sub.id. What should I do?

list < Main > .stream (). Sorted (Comparator.comparing (Main::getSub)) cannot be sorted by id.

Mar.02,2021

list.stream (). Sorted ((Sub1, Sub2)-> Sub1.getId (). CompareTo (Sub2.getId (). Collect (Collectors.toList ());


are you sure that answer is valid?

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-1b38093-2c0c7.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-1b38093-2c0c7.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?