You are standing at origin & there are many cars in the x,y plane which coordinates (x,y) .Sort the cars according minimum distance from origin , if the distance is same display the car with lesser x coordinate.
When i input the coordinates for 4 cars
as (1,1) , (0,1) , (1,0) ,(2,2)
I am getting output
(0,1)
(1,1)
(1,0)
(2,2)
but should get
(0,1)
(1,0)
(1,1)
(2,2)