File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
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.
Did you see how Paul
cut 87% off of his electric heat bill with 82 watts of micro heaters
subject: How to sort array list wich is contain diffrent objects
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?
Sorting a table based on a column
writing generic sort method
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2014