list集合根据某个字段进行排序

jobsStoreCounts:集合

x.getCount():字段

Integer.compare:字段类型

//正序

jobsStoreCounts.sort((x,y)->Integer.compare(x.getCount(),y.getCount()));

//倒序

jobsStoreCounts.sort((x,y)->Integer.compare(y.getCount(),x.getCount()));

你可能感兴趣的:(list集合根据某个字段进行排序)