Sorting ArrayList of Objects

thank all of you for the replies. i expect my doubts are well explained below.

i’ve already dumped the ArrayLists as sugested by @quark , i’m working directy with the entries ArrayList.

Does this mean that you have an ArrayList<Estado> that you want to sort? And you want them sorted by new cases from… the most recent entry, or a specific timestamp, or the largest historical entry, or…?

yes, i have an ArrayList<Estado> and an ArrayList<Cidade> in my main function. Right now I want the totalCases and numDeaths sorted for by max numbers for each day. I can do the daily visualizations right now but it’s not sorted. I have these functions pieChartStateCases and pieChartStateDeaths that do what is needed now without sorting. it’s just placing the sate sequences.

By “numDeaths” in an Entry, do you mean in a day / unit of time, or do you mean the cumulative total deaths?

My tables only have cumulative death data. I could implement daily difference calculator, but this will be in the next iteraction, as well as calculating the PPM.

all my sortings happens in the main function. they are called in the pieCharts functions. I kinda understand the implementation but did not fully grasped it. reading some documentation and seeing some examples still have doubts:

1.These comparators are ‘similar’ to ArrayLists? are they different data structures that use the original data without ‘destroying’ it or they do destroy? Because in my case, i need to keep them ‘safe’ because thay are already built cronologically.

  1. Do i place these comparators in the main function or in the State/City Object/
Comparator<Entry> entryCompByNew;
Comparator<Entry> entryCompByTotal;
Comparator<Entry> entryCompByDeaths;
  1. where do i call the sorting? in the setup, for this new data structure that i think should be
Comparator<Estado>compTotalCases;
Comparator<Estado>compTotalDeaths;
Comparator<Cidade>compTotalCases;

My main function concerning the handling of data

PGraphics pie1, pie2;
Table estado;//table with all states
Table cidade;//table with all cities
Table tabelaHistorico;// online table with all state data
Table tabslaHistoricoCidades; //online table with all city data

ArrayList<Estado> estados; //all states
Estado e;  //state that's being seen
ArrayList<Cidade> cidades; //all cities
Cidade c; //city that's being seen
ArrayList<Cidade> activeCities; //infected cities

in setup, i initialize the arraylists, build each state and city object and call all the functions to scrap the data dump and place the right data in the right object. that’s working fine by now.
also by key commands i toggle state/city view, horizontal keys iterate the visualization for each state/city and vertical key change daily visualization.