前些天發現了一個巨牛的人工智能學習網站,通俗易懂,風趣幽默,忍不住分享一下給大家。點擊跳轉到教程。
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);
?