# Sort PVector array by distance

**URL:** <https://discourse.processing.org/t/sort-pvector-array-by-distance/4737>\
**Category:** Coding Questions\
**Created:** [October 22, 2018, 7:47am UTC](https://discourse.processing.org/t/sort-pvector-array-by-distance/4737 "2018-10-22T07:47:42Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [October 22, 2018, 9:07am UTC](https://discourse.processing.org/t/sort-pvector-array-by-distance/4737/3 "2018-10-22T09:07:40Z")

</div>

Use the sketch from this link below as a model: 🤓

- [Forum.Processing.org/two/discussion/19469/sort-a-pvector-array#Item\_9](http://Forum.Processing.org/two/discussion/19469/sort-a-pvector-array#Item_9)

But change its Comparator::**compare()** to use **dist()** instead. 😛

---

_[View the full topic](https://discourse.processing.org/t/sort-pvector-array-by-distance/4737)._
