Re: sort list
- From: Roedy Green <look-on@xxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 19 Sep 2005 20:15:18 GMT
On 19 Sep 2005 08:41:11 -0700, vincent.fayolle@xxxxxxxxx wrote or
quoted :
>I have one list who contains other lists :
>
>
>Like :
>
>myList(
>{"Stephan","GUINVER",16,76},
>{"John","KENEDY",34,45},
>{"ELSA","ARMBRUSTER",8,64}
>}
>
>What is the syntax to sort this list by firstname or lastname or age
I would create an Person object with firstName, Surname, birthDate
(not age which goes stale daily) etc. fields. Then you can store the
objects in any sort of Collection. see
http://mindprod.com/jgloss/collection.html
If you define a Comparable natural order, the various sorted
Collections will keep things in order for you, or you can sort
explicitly an ArrayList or array. You can define an alternate order
with a Comparator.
See http://mindprod.com/jgloss/sort.html
http://mindprod.com/jgloss/comparable.html
http://mindprod.com/jgloss/compartor.html
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.
.
- References:
- sort list
- From: vincent . fayolle
- sort list
- Prev by Date: Re: switching values fast
- Next by Date: Re: JPRINTOUT 2.0.0 HAS BEEN RELEASED - pure java professional reporting solution for embedding in your application
- Previous by thread: Re: sort list
- Next by thread: Re: sort list
- Index(es):
Relevant Pages
|
|