ifeilong / feilong-core

:gem: Reduce development, Release ideas
Apache License 2.0
529 stars 155 forks source link

根据对象字段去重,不希望改变List顺序 #782

Closed DazonWu closed 4 years ago

DazonWu commented 5 years ago

就是我查了一堆数据,然后根据文件名去重,我需要的是总是显示createdAt这个字段最新的数据

List

id, path, createdAt 1 a.txt 10:00 2 b.txt 9:00 3 a.txt 11:00 4 c.txt 13:00 5 d.txt 15:00

id, path, createdAt 1 a.txt 10:00 2 b.txt 9:00 3 a.txt 11:00 4 c.txt 13:00 5 d.txt 15:00

venusdrogon commented 5 years ago

此时此刻 现有方案 可以

  1. sort(list, "createdAt desc")

  2. com.feilong.core.util.CollectionsUtil.groupOne(Iterable, String)

  3. map values

venusdrogon commented 4 years ago

com.feilong.core.util.CollectionsUtil.removeDuplicate(Collection, String...)

since 2.1.0 是你想要的

venusdrogon commented 4 years ago

see #808