Suppose i've an object like this LinkedHashMap<String, List<AuditLogs>>
. Where AuditLog class has property named modifiedDate
.
I want to sort auditlogs object on the basis of modifiedDate
irrespective of any key.
Although I've tried but it works me on the basis of keys.Can i have code snippet which work ignoring keys.
Assuming you want all the audit log values from all the keys in one list, sorted by modifiedDate
:
If your object is LinkedHashMap<String, List<AuditLogs>> map
:
List<AuditLog> sortedAuditLogs = map
.values()
.stream()
.flatMap(List::stream)
.sorted(Comparator.comparing(AuditLog::modifiedDate))
.collect(Collectors.toList());
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.