I have an archaist of records for the card game that I do. There must be a final limit on the number of points that this arraylist can store, which the user of the system can determine (say 10 at the moment). Fields in objects in arraylist are the playerβs name (string), their score (int) and (almost) unique identifier for the player (Long, System.currentTimeMillis ()). The arrailist should be sorted by score, where the lowest result is the best. However, if all players in the arraist have the same score and a new player is added with this score, I would like players with the most recent results (those for which the highest IDs) to be saved before the older ones, so the old ones are discarded.
Essentially, I need a way to sort the ArrayList into two fields: first the grade, low to high, and then if the grade matches sorting by ID. Removing unnecessary elements, which I have already mainly considered, although if there is a way to integrate, I would be interested to hear it.
EDIT: I'm trying to sort Arraylist objects with these attributes, and not just one arraylist with them just throws. My bad.
source share