Sort:  

It is for many programming brains as well ;) But this is a good problem to solve. I have been lazy and posed a Gig. Ideally I would have liked to spend time on this and come out with a solution. Now I will atleast analyse the solutions provided.