A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Win a copy of
Android Security Essentials Live Lessons
this week in the
Java in General
How to sort array list wich is contain diffrent objects
Joined: Jul 22, 2010
Aug 25, 2010 00:19:49
I have a arraylist which contains objects
Serviceprovider serv; while(result.next()) serv = new Serviceprovider(); arraylist.add(serv); }
In serv object i have different listing fields like name , email, postedate etc.
I have to sort this arraylist by postedate .
I do not want to write it in query because on later stage i divide this arraylist in two
How can i do it.
Please help for that
Thanks in advance .
Jesper de Jong
Joined: Aug 16, 2005
Aug 25, 2010 01:24:06
Use the method
that takes a
is the thing that determines how the objects are sorted; implement your own
that compares the objects by the fields that you want to sort on.
Java Beginners FAQ
JavaRanch SCJP FAQ
The Java Tutorial
Java SE 7 API documentation
- My blog about Scala
Joined: Oct 13, 2005
Aug 25, 2010 05:55:23
If the contents of your List are not appropriate for the Comparator<T>, you will suffer a
. That is why you ought to be using the generic version of the List.
I agree. Here's the link:
subject: How to sort array list wich is contain diffrent objects
Sorting a table based on a column
using the RMI registry for accessing a DataSource via JNDI ?
Sorting two Classes
Non-Networked Mode. How could be demostrated no networking is beeing performed?
writing generic sort method
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2014