1
I have an Arraylist called Test with the fields:
public class Teste
{
private String dctitle;
private String rdfabout;
private String dbid;
private String depto;
private String sigla;
private String ciclo;
private String state;
private String dataplanejadainicial;
private String dataEntradaEstado;
private String id;
private String executante;
}
This Arraylist has N items and I need to create a "sort" method that will receive as parameter the ArrayList<Teste> teste
and return me an Arraylist with Testing ordered by the Departments.
I know you have a method called .Sort but I don’t know how to use.
NOTE: in the Test class are implemented all the Get and Set attributes, just not put to not make the question too big
so I’m trying to understand how this . Sort it returns me a new array already in order, from the first item to the last?
– Mari Teixeira
This @Mariteixeira he will catch that
array
and order for you all the elements contained, in case I made the comparison ongetDepto()
which would be the department!. Actually it’s the same ordered array.– novic
@Mariteixeira was clear the answer?
– novic
was... I’m just getting mixed up in the use. I thought of creating a "new array" already sorted pq I will have to use this array in other methods as well. Like this function
.sort
does not return a new one, it changes the array being passed as parameter, I have to do this methodCollections.sort
every time I need it ordered?– Mari Teixeira
@Mariteixeira will be used only when it is not ordered and of course you need to order it, example change in the array, how to increase the
array
as new items...– novic
I’ll have to use it at all times ordained
– Mari Teixeira
I did it! Thank you, I was confused but now I got it!
– Mari Teixeira