Sorting of a Collection

I have a collection of Objects of a Class, this Object contains another collection within it. i.e Class A contains a collection of Class B objs.

Now I want to sort elements of Collection B and based on its probability sort collection A ......I have an object C of same type as obj B of same class say B . Now I need to iterate through the collection B and compare values in obj B and C and accordingly sort B based on most number of matched found. Based on comparision of B and C I need to decide how A would be sorted .......

I have

A -- a1b1(Obj of B)

b2 (Obj of B)

b3 (Obj of B)

A - a2b1

b2

b3

c (Obj og B) .....

if c.x = b1.x and c.y = b1.y than b1 is should come at the top of the list.

if c.x =b.x and c.x != b1.y than it has less priority than the condition above . accordingly I need to sort b1,b2 and b3 within a1 ......

If I see that all b1,b2 and b3 for a1 are equal to x,y for c than a1 also holds a high priority and accordingly I need to sort A..

Please let me know some also using which I can sort this.

[1107 byte] By [Rohan.Desaia] at [2007-11-27 6:51:23]
# 1
Well, I read that twice and got lost both times. Anyway, you would write a Comparator which did whatever you were trying to explain there.
DrClapa at 2007-7-12 18:25:46 > top of Java-index,Core,Core APIs...
# 2
A comparator will be used to omare two elements in the collection , we want to compare a third object wit the ones in the collection . If I use Collection.sort(list,comparator) , I will end up sorting elements in a list but I want to compare it with a third object .
Rohan.Desaia at 2007-7-12 18:25:46 > top of Java-index,Core,Core APIs...
# 3
I got it thanks !! I could manage this without a comparator
Rohan.Desaia at 2007-7-12 18:25:46 > top of Java-index,Core,Core APIs...