custom sorting a java array

前端 未结 4 930
长情又很酷
长情又很酷 2021-01-06 03:41

I have an [] that has some numbers (distances from some point).
I want to create an array of indexes into the first array where the indexes are sorted by the distance.

4条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-06 04:18

    You should customize your own Comparator and use java API.

    http://docs.oracle.com/javase/6/docs/api/java/util/Arrays.html#sort(java.lang.Object[],%20int,%20int)

    http://docs.oracle.com/javase/tutorial/collections/interfaces/order.html

提交回复
热议问题