如何以升序具有数组列表元素,如排序字母数字数组列表按照升序
02112-S1530
02112-S1529
02112-S1531
排序。
我正在使用Collection.sort(List name);
但得到的输出
02112-S1531
02112-S1529
02112-S1530
预期成果是:
02112-S1529
02112-S1530
02112-S1531
我不喜欢
List<String> gbosIdsList = new ArrayList<String>();
gbosIdsList.add("02112-S1530");
gbosIdsList.add("02112-S1529");
gbosIdsList.add("02112-S1531");
Collections.sort(gbosIdsList);
Iterator itr = gbosIdsList.iterator();
while(itr.hasNext()){
System.out.println(itr.next());
}
使用比较器对字母数字式数组列表进行排序。 – 2013-03-19 10:02:54
你需要定义你自己的'comapartor'.There你可以修改比较标准排序.. – Anubhab 2013-03-19 10:03:17
我不认为有什么理由downvote这篇文章。 – Maroun 2013-03-19 10:04:01