mapTest
import java.util.*;
public class mapTest {
public static void main(String[] args) throws Exception{
List<Map<String,Object>> list = new ArrayList(){
{
add (new HashMap(){{put("a","1");put("","0");}});
add (new HashMap(){{put("a","11");put("b","2");}});
add (new HashMap(){{put("a","111");put("c","3");}});
add (new HashMap(){{put("b","22");}});
add (new HashMap(){{put("a","1111");put("b","222");}});
}
};
sort(list);
}
private static void sort(List<Map<String,Object>> l) {
int temp = 0;
List<Map<String,Object>> l1= new ArrayList<>();
for (int k = 0; k < l.size(); k++) {
String s = (String) l.get(k).get("a");
if (s != null) {
l1.add(l.get(k));
//int a = Integer.parseInt(s);
}
}
int[] arr = new int[l1.size()];
for(int m=0;m<l1.size();m++){
String s = (String) l1.get(m).get("a");
arr[m] = Integer.parseInt(s);
}
for (int i = 0; i < arr.length; i++) {
for (int j = i + 1; j < arr.length; j++) {
if (arr[i] > arr[j]) {
temp = arr[i];
arr[i] = arr[j];
arr[j] = temp;
}
}
}
for (int i = 0; i < l1.size(); i++) {
System.out.println(arr[i]+"="+l1.get(i));
//System.out.println(l1.get(i));
}
}
}