# OrderedSet indexing

**URL:** https://discourse.julialang.org/t/orderedset-indexing/27018
**Category:** General Usage
**Created:** [July 31, 2019, 6:34am UTC](https://discourse.julialang.org/t/orderedset-indexing/27018 "2019-07-31T06:34:25Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![tk3369](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tk3369/32/2824_2.png) [@tk3369](https://discourse.julialang.org/u/tk3369)
#### Post date: [July 31, 2019, 6:34am UTC](https://discourse.julialang.org/t/orderedset-indexing/27018/1 "2019-07-31T06:34:25Z")

</div>

Any idea why `OrderedSet` indexing is deprecated? If I follow the recommendation then I would have to keep a counter and iterate until I find the `i`th item?

```julia
julia> using DataStructures

julia> os = OrderedSet([2,3,1,4,7,6])
OrderedSet{Int64}([2, 3, 1, 4, 7, 6])

julia> os[2]
┌ Warning: indexing is deprecated for OrderedSet, please rewrite your code to use iteration
│ caller = top-level scope at none:0
└ @ Core none:0
3

```

---

<div class="post-metadata">

### Author: ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)
#### Post date: [July 31, 2019, 7:19am UTC](https://discourse.julialang.org/t/orderedset-indexing/27018/2 "2019-07-31T07:19:35Z")

</div>

If you try

```julia
@edit os[2]

```

it will take you to the relevant method, above which you find a reference to

[https://github.com/JuliaCollections/DataStructures.jl/pull/180#issuecomment-400269803](https://github.com/JuliaCollections/DataStructures.jl/pull/180#issuecomment-400269803)

which explains the reason.

In case the code did not have a comment like this, use the Github “blame” functionality on source files:

[https://github.com/JuliaCollections/OrderedCollections.jl/blame/master/src/ordered\_set.jl](https://github.com/JuliaCollections/OrderedCollections.jl/blame/master/src/ordered_set.jl)

to find the PR/commit that changed something.

---

<div class="post-metadata">

### Author: ![tk3369](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tk3369/32/2824_2.png) [@tk3369](https://discourse.julialang.org/u/tk3369)
#### Post date: [July 31, 2019, 7:23am UTC](https://discourse.julialang.org/t/orderedset-indexing/27018/3 "2019-07-31T07:23:25Z")

</div>

Thanks.

And, I agree with [this comment](https://github.com/JuliaCollections/DataStructures.jl/pull/180#issuecomment-484877416) 🙂
