Collision in a stack

Hi,
I am making a prototype game just for research purpose! Its basically a vertical stacking game! The user has to stack boxes on top of one another! The problem is that we have a win situation when the last block is placed on top of the stack! So far i have used the "ContactListener" implementation to store all the objects which collide in a vector... But is it possible to get the last topmost objects collided??? I have tried various methods but without luck!!
Sort by the y-value?
hmm!! But is there any other way i can test collisions optimizing the processing?? coz when we use ContactListener and two or more blocks are stacked over one another, it keeps showing collision for all the blocks... any suggestions...

And i have managed to check the collision using tag feature, i give a unique tag to the sprite associated with the last block! Has solved the problem! Do u think it could create any problem for me???

Original thread: https://box2d.org/forum/viewtopic.php?t=5520