集合:按元素的中文属性排序
生活随笔
收集整理的這篇文章主要介紹了
集合:按元素的中文属性排序
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
前些天發現了一個巨牛的人工智能學習網站,通俗易懂,風趣幽默,忍不住分享一下給大家。點擊跳轉到教程。
1. 要排序的元素類:
public static class NameCount implements Comparable<NameCount> {Collator collator = Collator.getInstance(java.util.Locale.CHINA);@ApiModelProperty(value = "名")private String name;@ApiModelProperty(value = "次數")private Integer count;public String getName() {return name;}public void setName(String name) {this.name = name;}public Integer getCount() {return count;}public void setCount(Integer count) {this.count = count;}@Overridepublic int compareTo(NameCount o) {return collator.compare(this.name, o.getName());}}2. 集合:
List<NameCount> NameCountList = Lists.newArrayList();該集合中有多個元素后,按name排序的實現:
Collections.sort(NameCountList);?
總結
以上是生活随笔為你收集整理的集合:按元素的中文属性排序的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: c#调用c++(Opencv)dll的实
- 下一篇: OpenCV图像锐化/增强