摘要: 1. 按照key值排序 对于java中Map的排序,有排序Map,比如TreeMap,对于这个Map,首先只能按照键排序,其次再put和remove的时候由于需要排序,性能上会有所牺牲。 这种方案,使用hashmap进行创建和添加,如果需要按照key排序,则可以将该hashmap作为参数传递到new TreeMap(hashmap),则可以完成按照key的排序。 TreeMap treemap = new TreeMap(hashmap);2. 按照value值排序 使用TreeMap,用List封装,然后添加比较器,进行排序 List> list = new ArrayList> 阅读全文
posted @ 2014-01-08 16:26 踏刃而起 阅读(1052) 评论(0) 推荐(0)