package stp;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.stream.Collectors;
public class RcDb {
public static void main(String[] args) {
String ss = "wo de de de woowo de ww dd mm nn mm m";
String[] numstr = ss.split(" ");
ArrayList<String> srcids = new ArrayList<>(Arrays.asList(numstr));
Map<String, Long> collect =srcids.stream()
.collect(Collectors.groupingBy(v->v,Collectors.counting()));
System.out.print(collect);
//结果 {nn=1, mm=2, dd=1, ww=1, de=4, wo=1, m=1, woowo=1}
// 排序
List<Entry<String, Long>> ds = collect.entrySet().stream()
.sorted((y,x)->x.getValue().compareTo(y.getValue())).collect(Collectors.toList());
System.out.print(ds);
//结果 [de=4, mm=2, nn=1, dd=1, ww=1, wo=1, m=1, woowo=1]
}
}