current position:Home>Sort a list using stream

Sort a list using stream

2022-09-23 09:32:49Pharmacist YS

Listsort

Positive order

list.stream().sorted(Comparator.comparing(Entity::getId)).collect(Collectors.toList());

Reverse order

list.stream().sorted(Comparator.comparing(Entity::getId).reversed()).collect(Collectors.toList());

copyright notice
author[Pharmacist YS],Please bring the original link to reprint, thank you.
https://en.chowdera.com/2022/266/202209230926246796.html

Random recommended