Java-Sortierproblem
为情所困
为情所困 2017-05-27 17:40:50
0
1
539

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

Dies ist eine Liste im Format List<Map<String,Object>. Darin befindet sich eine Karte, die ich nach dem Format TIME0, TIME1, TIME2...TIME23 sortieren möchte. Wolltuch? Und Typen wie TIME1 sind BigDecimal. Machen Sie sich keine Sorgen über LOAN_AMT und REG_DT im Inneren, ich verwende einfach die Schleife, um die TIMExx-Informationen abzurufen

为情所困
为情所困

Antworte allen(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}
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage