I am sending result in descending order but I get output with ascending order
List<myEntity> myData = new ArrayList<>();
Map<Integer,List<myEntity>> myid = new LinkedHashMap<>();
try {
myData = myService.getData(id);
myid = myData.stream().collect(Collectors.groupingBy(myEntity::getDataId));
Here mydata is sorted by desc order but after creating collections by group data id my list get sorted with ascending order. I want my collection list to be descending order not ascending order.
Collections.reverse(myData);
– Moulmeinmyid
map, or themyEntity
inside the list? – AdamicCollectors.groupingBy(myEntity::getDataId, LinkedHashMap::new, Collectors.toList())
– Adamic