# Ordered arrays

**URL:** <https://discourse.julialang.org/t/ordered-arrays/45258>\
**Category:** General Usage\
**Created:** [August 20, 2020, 10:03am UTC](https://discourse.julialang.org/t/ordered-arrays/45258 "2020-08-20T10:03:25Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mamo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mamo/32/25591_2.png) [@mamo](https://discourse.julialang.org/u/mamo)\
**Post date:** [August 20, 2020, 10:03am UTC](https://discourse.julialang.org/t/ordered-arrays/45258/1 "2020-08-20T10:03:25Z")

</div>

If I have a Dict:

P=Dict(“F1”=\>(“a30”, “a37”), “F2”=\>(“a10”, “a11”, “a12”),  
“F3”=\>(“a15”, “a22”, “a31”))  
how to make it ordered - when it is used to be used by order - F1,F2,F3…?  
Thank you!  
Marco

---

<div class="post-metadata">

**Author:** ![anon37204545](https://avatars.discourse-cdn.com/v4/letter/a/439d5e/32.png) [@anon37204545](https://discourse.julialang.org/u/anon37204545)\
**Post date:** [August 20, 2020, 10:14am UTC](https://discourse.julialang.org/t/ordered-arrays/45258/2 "2020-08-20T10:14:56Z")

</div>

Two options:

1. make it an array of pairs, which is absolutely possible

```julia
P = [“F1”=>(“a30”, “a37”), “F2”=>(“a10”, “a11”, “a12”),
“F3”=>(“a15”, “a22”, “a31”)]

```

1. use an OrderedDict from [OrderedCollections.jl](https://github.com/JuliaCollections/OrderedCollections.jl) or [DataStructures.jl](https://github.com/JuliaCollections/DataStructures.jl)

---

<div class="post-metadata">

**Author:** ![mamo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mamo/32/25591_2.png) [@mamo](https://discourse.julialang.org/u/mamo)\
**Post date:** [August 20, 2020, 10:34am UTC](https://discourse.julialang.org/t/ordered-arrays/45258/3 "2020-08-20T10:34:29Z")

</div>

Hvala Zlajo!

---

<div class="post-metadata">

**Author:** ![mamo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mamo/32/25591_2.png) [@mamo](https://discourse.julialang.org/u/mamo)\
**Post date:** [August 21, 2020, 10:28am UTC](https://discourse.julialang.org/t/ordered-arrays/45258/4 "2020-08-21T10:28:09Z")

</div>

Please, advice in case of following error:  
ERROR: LoadError: MethodError: no method matching getindex(::OrderedSet{String}, ::UnitRange{Int64})  
Closest candidates are:  
getindex(::OrderedSet, ::Int64) at C:\Users\mmill.julia\packages\OrderedCollections\P6ntV\src\ordered\_set.jl:78

---

<div class="post-metadata">

**Author:** ![pdeffebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pdeffebach/32/10320_2.png) [@pdeffebach](https://discourse.julialang.org/u/pdeffebach)\
**Post date:** [August 21, 2020, 11:55am UTC](https://discourse.julialang.org/t/ordered-arrays/45258/5 "2020-08-21T11:55:49Z")

</div>

Please post example code in backticks

````julia
``` 
like this, code here
```

````

You problably want `d.[[1, 2, 3]]` . Notice the broadcasting, the `d.` rather than `d[[1, 2, 3]]`.
