public class Leaderboard extends RealmObject {
String score;
}
RealmResults<Leaderboard> leaderboardList = realm.where(Leaderboard.class).distinct("score").findAll();
The results are Strings
which are actually just large numbers stored as String
since Realm does not support BigInteger
. What I need to do is output those numbers in numerical order.
Cannot use Collections(sort)
since min sdk is 16. No luck using StreamSupport lib either. I am currently trying to convert RealmResults
to a simple array of strings so I can do the sorting on that but I'm having trouble. The following results in a cast error, but even before changes would result in ldrStrings.get(0)
outputting something like proxy[((75000))]
which is the real number but surrounded by that text:
RealmResults<Leaderboard> leaderboardList = realm.where(Leaderboard.class).distinct("score").findAll(); Leaderboard[] leaderboardArray = (Leaderboard[]) leaderboardList.toArray(); List<String> ldrStrings = new ArrayList(leaderboardArray.length); for (Object object : leaderboardArray) { ldrStrings.add(object != null ? object.toString() : null); } Collections.sort(ldrStrings, new Comparator<String>() { @Override public int compare(String o1, String o2) { BigInteger bi1 = new BigInteger(o1); BigInteger bi2 = new BigInteger(o2); return bi1.compareTo(bi2); } });