Код: Выделить всё
List myData = new ArrayList();
Map myid = new LinkedHashMap();
try {
myData = myService.getData(id);
myid = myData.stream().collect(Collectors.groupingBy(myEntity::getDataId));
Подробнее здесь: https://stackoverflow.com/questions/521 ... order-java