# \#sets

**URL:** https://discourse.julialang.org/tag/sets/646.md

[Latest](https://discourse.julialang.org/latest.md) · [Categories](https://discourse.julialang.org/categories.md) · [Tags](https://discourse.julialang.org/tags.md)

---

## [Get an equal element of a set/get an equal key of a dictionary](https://discourse.julialang.org/t/get-an-equal-element-of-a-set-get-an-equal-key-of-a-dictionary/128779)

<div class="topic-metadata">

**Author:** [@nsajko](https://discourse.julialang.org/u/nsajko)\
**Replies:** 4\
**Last updated:** [May 7, 2025, 3:52pm UTC](https://discourse.julialang.org/t/get-an-equal-element-of-a-set-get-an-equal-key-of-a-dictionary/128779 "2025-05-07T15:52:26Z")

</div>

Suppose I have x and s::AbstractSet and I know x ∈ s. How to get the element of s, say e, such that x == e? I could iterate through all elements like this, but surely there should be a simpler and more efficient solution…

---

## [How to define \`:(==)\` on user-defined types for \`Set\` operations](https://discourse.julialang.org/t/how-to-define-on-user-defined-types-for-set-operations/126391)

<div class="topic-metadata">

**Author:** [@drbergman](https://discourse.julialang.org/u/drbergman)\
**Replies:** 2\
**Last updated:** [March 3, 2025, 3:51pm UTC](https://discourse.julialang.org/t/how-to-define-on-user-defined-types-for-set-operations/126391 "2025-03-03T15:51:34Z")

</div>

I want to create a Set{MyType} object, but use a custom Base.:(==) to compare instances of MyType. It seems that the dispatch of in is not making use of Base.:(==) (or Base.isequal for that matter) despite what the docum…

---

## [Edge case in Sets with Floats](https://discourse.julialang.org/t/edge-case-in-sets-with-floats/78787)

<div class="topic-metadata">

**Author:** [@fatteneder](https://discourse.julialang.org/u/fatteneder)\
**Replies:** 6\
**Last updated:** [March 31, 2022, 12:25pm UTC](https://discourse.julialang.org/t/edge-case-in-sets-with-floats/78787 "2022-03-31T12:25:00Z")

</div>

Hi Julia Community, recently I was approached by a colleague who just got started with Julia and ran into a problem that took him ages to debug. We then seat down together and could come up with the following MWE: juli…

---

## [How to call an element of a set?](https://discourse.julialang.org/t/how-to-call-an-element-of-a-set/68648)

<div class="topic-metadata">

**Author:** [@leon](https://discourse.julialang.org/u/leon)\
**Replies:** 9\
**Last updated:** [September 24, 2021, 1:38am UTC](https://discourse.julialang.org/t/how-to-call-an-element-of-a-set/68648 "2021-09-24T01:38:57Z")

</div>

Sorry for the very silly question. I’m trying to figure out how to call the elements of a set. For example in my below example, how do I get the first element, i.e., “Acg”? A = Set(\[“Acg”, “Bdc”, “HH”\]); I tried, A\[1\],…

---

## [Opposite of unique](https://discourse.julialang.org/t/opposite-of-unique/57802)

<div class="topic-metadata">

**Author:** [@Ribeiro](https://discourse.julialang.org/u/Ribeiro)\
**Replies:** 19\
**Last updated:** [March 25, 2021, 12:37pm UTC](https://discourse.julialang.org/t/opposite-of-unique/57802 "2021-03-25T12:37:22Z")

</div>

Hi! Is there a function that does the opposite of unique? Say nonunique(\[1,2,3,4,3,5,3,2\]) = \[2,3\] Thanks a lot!

---

## [Can you sort a Set?](https://discourse.julialang.org/t/can-you-sort-a-set/47948)

<div class="topic-metadata">

**Author:** [@anon60034542](https://discourse.julialang.org/u/anon60034542)\
**Replies:** 9\
**Last updated:** [October 7, 2020, 9:29pm UTC](https://discourse.julialang.org/t/can-you-sort-a-set/47948 "2020-10-07T21:29:54Z")

</div>

In Python, I can do: a = set(\[2,1,5,3,2\]) b = sorted(a) print(b) # Returns a sorted List In Julia, Is it possible to sort a Set? Edit: There is no particular reason why I require a Set. I was reading the documentatio…
