Use Collections.sort(list, new Comparator() {...});

or Collections.sort(list) if your Plan class implements Comparable

Nico.

Krishna Mohan Radhakrishnan a écrit :

Hi all,

I have a doubt regarding sorting in array List.

I have an array List  which contains array list objects of type Plan.

The Plan object contains 3 variables : plantitle ,plandescription and
planname.

I have to sort the arraylist based on the plantitle first and then based
on the plandescription.


ArrayList list = new ArrayList(); Plan planobj = null; For (i= 1, i<=100, i++){ planObj = readPlanObjectFromDB(); list.add(planObj);

}

//?? Now how to sort it


Private Plan readPlanObjectFromDB(){ //queries the database to return plan object

return plan;
}

I am totally confused. Even if use bubble sorting it will cause a lot of
performance issues.

Could any one please suggest me a good method?

Regards,
Krishna Mohan


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]





This message contains information that may be privileged or confidential and is the property of the Capgemini Group. It is intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorized to read, print, retain, copy, disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message.


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to