How to find the coordinate that is closest to the point of origin?

后端 未结 2 1661
滥情空心
滥情空心 2020-12-06 14:42

I know there are many many questions about sorting javascript arrays by multiple values, but none of the answers solved my problem.

I have an array of coordinates li

2条回答
  •  天涯浪人
    2020-12-06 15:16

    For each x,y pair, square x, square y and add together. Smallest number is nearest to the origin.

提交回复
热议问题