java sorting problem
为情所困
为情所困 2017-05-27 17:40:50
0
1
540

[{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}]

This is a list in the format of List<Map<String,Object>>. Inside is a map. I want to sort it according to the format of TIME0, TIME1, TIME2...TIME23 after sorting. How to sort? And types like TIME1 are BigDecimal. Don’t worry about the LOAN_AMT and REG_DT inside, I just use the loop to get the TIMExx information

为情所困
为情所困

reply all(1)
漂亮男人

In fact, you only need to List<Map<String,Object>>改成List<TreeMap<String,Object>>...
TreeMap is sorted by 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}
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template