Leandro, is this a standalone collection (as returned from an action
invocation) or is it a "parented" collection?

In either case Oscar's recommendation for using a SortedSet is probably
appropriate, but you should pretty much ALWAYS use a SortedSet for parented
collections.

Dan


On 29 September 2014 16:36, GESCONSULTOR - Óscar Bou <[email protected]
> wrote:

>
>
> It would be better, if you want it to be automatically sorted by means of
> the standard Java "compareTo" method.
>
> That way, the result set will always be sorted.
>
> But look also at the second example that uses a "custom" Comparator, so
> can sort in a different order than the one specified by means of the
> "compareTo" method.
>
>
> Perhaps it's of your interest the following discussion on Stack Overflow
> regarding the "no existence" of a SortedList class in Java [1].
>
>
> Regards,
>
> Oscar
>
>
> [1]
> http://stackoverflow.com/questions/8725387/why-there-is-no-sortedlist-in-java
>
>
>
>
> El 29/09/2014, a las 17:28, Leandro Torroija <[email protected]>
> escribió:
>
>
> Hi Oscar!
>
> I'm using java.util.List. Is it better to use a SortedSet collection?
>
> thanks!
> Leandro
>
>
>
> Subject: Re: Sorted collection
> From: [email protected]
> Date: Mon, 29 Sep 2014 16:01:55 +0200
> To: [email protected]
>
>
> Hi, Leandro.
>
> Are you returning a SortedSet instead of simply a Set?
>
> If so, you can customize the order by:
> 1. implementing a compareTo method that takes the order you want,
> 2. defining a custom sorting for the collection.
>
> For both cases, you will find examples on the ToDoItem class on [1].
> There, search for:
>
> 1. --> public int compareTo(final ToDoItem other) {
> 2. --> @SortedBy(DependenciesComparator.class)
>
> And see the comments.
>
>
> HTH,
>
> Oscar
>
>
> [1]
> https://github.com/apache/isis/blob/master/example/application/todoapp/dom/src/main/java/dom/todo/ToDoItem.java
>
>
>
>
> El 29/09/2014, a las 15:57, Leandro Torroija <[email protected]>
> escribió:
>
> hi everybody!
>
> When you have selected an object, which has a collection. Is there any way
> to sort these objects by criteria?
> Or do I have to create a ViewModel and fill the collection already sorted
> through a query to the database?
>
> Thanks!
>
> Leandro.
>
>
>
>
>
>
>
>
>
>
>
> Óscar Bou Bou
> Responsable de Producto
> Auditor Jefe de Certificación ISO 27001 en BSI
> CISA, CRISC, APMG ISO 20000, ITIL-F
>
>    902 900 231 / 620 267 520
>    http://www.twitter.com/oscarbou
>
>    http://es.linkedin.com/in/oscarbou
>
>    http://www.GesConsultor.com <http://www.gesconsultor.com/>
>
>
>
> Este mensaje y los ficheros anexos son confidenciales. Los mismos
> contienen información reservada que no puede ser difundida. Si usted ha
> recibido este correo por error, tenga la amabilidad de eliminarlo de su
> sistema y avisar al remitente mediante reenvío a su dirección electrónica;
> no deberá copiar el mensaje ni divulgar su contenido a ninguna persona.
> Su dirección de correo electrónico junto a sus datos personales constan en
> un fichero titularidad de Gesdatos Software, S.L. cuya finalidad es la de
> mantener el contacto con Ud. Si quiere saber de qué información disponemos
> de Ud., modificarla, y en su caso, cancelarla, puede hacerlo enviando un
> escrito al efecto, acompañado de una fotocopia de su D.N.I. a la siguiente
> dirección: Gesdatos Software, S.L. , Paseo de la Castellana, 153 bajo -
> 28046 (Madrid), y Avda. Cortes Valencianas num. 50, 1ºC - 46015 (Valencia).
> Asimismo, es su responsabilidad comprobar que este mensaje o sus archivos
> adjuntos no contengan virus informáticos, y en caso que los tuvieran
> eliminarlos.
>
>
>
>
>
>

Reply via email to