How to search sort arraylist which has a number value in front of it, the plan is I want to sort the listview with the largest to the smallest number
private void setupData(){
ArrayList<String> hasil = new ArrayList<>();
Set<String> keySet = chains.keySet();
for(String key : keySet){
float ms = Float.parseFloat(chains.get(key).get(0));
float ma = 0;
for(String str : chains.get(key)){
if(str.contains(","))
ma += Float.parseFloat(str.split(",")[1]);
}
float pa = ma * 100;
String namaGangguan = SQLiteHelper.getInstance(this).getGangguan(key).getNama();
hasil.add((int)pa + " % " + namaGangguan); // this is i want sorting
}
Collection.sort(hasil); //this is my code
ArrayAdapter<String> diagnoseAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, hasil);
listView.setAdapter(diagnoseAdapter);
}
How to search sort arraylist which has a number value in front of it, the plan is I want to sort the listview with the largest to the smallest number