# What's the best way to compare items in an array to every other item?

**URL:** <https://discourse.julialang.org/t/whats-the-best-way-to-compare-items-in-an-array-to-every-other-item/26806>\
**Category:** General Usage\
**Tags:** performance, strings, arrays\
**Created:** [July 25, 2019, 6:17pm UTC](https://discourse.julialang.org/t/whats-the-best-way-to-compare-items-in-an-array-to-every-other-item/26806 "2019-07-25T18:17:04Z")\
**Posts on this page:** 1\
**Showing post:** 9

<div class="post-metadata">

**Author:** ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Post date:** [July 26, 2019, 1:43pm UTC](https://discourse.julialang.org/t/whats-the-best-way-to-compare-items-in-an-array-to-every-other-item/26806/9 "2019-07-26T13:43:36Z")

</div>

I think Tamas’ point is exactly right, `compare` will be your issue here - I asked a similar question [a while ago](https://discourse.julialang.org/t/why-do-these-two-functions-benchmark-the-same/12831) and the advice (rightly as it turned out) was a similar one.

What that means I guess is that it can pay to think a bit more about how you can minimize the number of comparisons you have to do, e.g. normalise strings (lowercase and remove spaces) and remove exact duplicates first, maybe remove duplicates immediately so that they don’t get compared again etc. and any other tricks which might be problem specific!

---

_[View the full topic](https://discourse.julialang.org/t/whats-the-best-way-to-compare-items-in-an-array-to-every-other-item/26806)._
