I have a custom class called "ergebnisse" with several fields, one of them is score of type Long
.
I want to sort an ArrayList<ergebnisse>
by score.
I tried a lot of things, but most most are fore one or two columns.
ArrayList<ergebnisse> list = new ArrayList<ergebnisse>();
Cursor data = mDatabaseHelper.fetchNamesByConstraint(filter);
while(data.moveToNext()){
//get the value from the database in column 1
//then add it to the ArrayList
String name = data.getString(1);
String scorestring = data.getString(2);
Long score=Long.parseLong(scorestring);
String timestring = data.getString(3);
Double time= Double.parseDouble(timestring);
String mode = data.getString(5);
String game = data.getString(4);
String levstring = data.getString(6);
Integer lev=Integer.parseInt(levstring);
list.add(new ergebnisse(name,score,time,mode,lev,game));
}
I want to sort from highest to lowest score.