Car sorting problem

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)

hi @ujj1804_1156aee80205d0bf
there was just a small error in ur code
image
here after if condition, u have written semi colon, just remove that, ur code will work fine…

corrected code -->

Thank you sir for helping.

1 Like

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.