'How to sort using streams? [closed]

int i = 0;    
return events.stream()
            .sorted(Comparator.comparing(Event::getMajorVersion).thenComparing(Event::getMinorVersion))
            .collect(Collectors.groupingBy(Event::getId, Collectors.toMap(cae -> cae.getMajorVersion() + "." + cae.getMinorVersion(),
                    cae -> cae.getDate().get(i).getEndDate() != null ? "Yes" : "No")));
}

By doing this I am not getting the desired sorted output? What can I do here to get the sorted data?



Solution 1:[1]

You can try it.

def pop(self):
if len(self.items) > 0:
    return self.items[1].pop(0)

Her items[1] is items[items list index]

items = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Md. Ali Haider