java 排序的问题
为情所困
为情所困 2017-05-27 17:40:50
0
1
549

[{TIME21=0, TIME22=2, TIME23=0, TIME12=0, TIME13=1, LOAN_AMT=500, TIME10=0, TIME20=0, TIME11=1, TIME17=0, TIME9=2, TIME16=0, TIME15=0, TIME14=1, TIME5=0, REG_DT=20170517, TIME6=0, TIME19=0, TIME7=0, TIME18=1, TIME8=4, TIME1=0, TIME2=0, TIME3=0, TIME4=0, TIME0=0}, {TIME21=3, TIME22=2, TIME23=3, TIME12=6, TIME13=7, LOAN_AMT=1000, TIME10=8, TIME20=2, TIME11=6, TIME17=6, TIME9=7, TIME16=2, TIME15=7, TIME14=5, TIME5=0, REG_DT=20170517, TIME6=1, TIME19=1, TIME7=3, TIME18=1, TIME8=5, TIME1=0, TIME2=1, TIME3=0, TIME4=0, TIME0=3}]

这是一个形式为List<Map<String,Object>> 格式的list,里面是map,我想经过排序后让其按照TIME0,TIME1,TIME2.....TIME23的形式排序,该怎么排序呢?而且类似 TIME1 这种的类型是BigDecimal。里面的LOAN_AMT和REG_DT不用管,我只是用循环得到TIMExx这些信息

为情所困
为情所困

全部回复(1)
漂亮男人

其实,你只需要把List<Map<String,Object>>改成List<TreeMap<String,Object>>就可以了.....
TreeMap是按照Kay进行排序的。

TreeMap<String,Object> map = new TreeMap<>();
map.put("TIME0","TIME0");
map.put("TIME22","TIME22");
map.put("TIME15","TIME15");
map.put("TIME11","TIME11");
map.put("TIME19","TIME19");
map.put("TIME1","TIME1");

System.out.println(map); // {TIME0=TIME0, TIME1=TIME1, TIME11=TIME11, TIME15=TIME15, TIME19=TIME19, TIME22=TIME22}
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板