# Does pmap() return in order?

**URL:** <https://discourse.julialang.org/t/does-pmap-return-in-order/27829>\
**Category:** General Usage\
**Tags:** distributed\
**Created:** [August 22, 2019, 2:43am UTC](https://discourse.julialang.org/t/does-pmap-return-in-order/27829 "2019-08-22T02:43:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jchen975](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jchen975/32/8994_2.png) [@jchen975](https://discourse.julialang.org/u/jchen975)\
**Post date:** [August 22, 2019, 2:43am UTC](https://discourse.julialang.org/t/does-pmap-return-in-order/27829/1 "2019-08-22T02:43:11Z")

</div>

Let’s say I have a function `f` where I do something with the `i`th column of a matrix available to all workers (~40). I then return an array of `Any` and length 4:

```julia
@everywhere function f(i:Int)
    //do something with the i-th column of matrix
    ret = Array{Any}(undef, 4)
    // write results to ret[1] to ret[4]
    return ret
end

function main()
    ret = pmap(f, 1:N)
end

```

When I do `ret = pmap(f, 1:N)` where N is large (e.g. 10k), is it guaranteed that the `ret` will be in order, i.e. the `ret[i]` will be the results from the `i`th column?

I ran a test case where N = 200 and seems like it is. If it actually is, then I won’t need to change my implementation.

---

<div class="post-metadata">

**Author:** ![yuyichao](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yuyichao/32/20_2.png) [@yuyichao](https://discourse.julialang.org/u/yuyichao)\
**Post date:** [August 22, 2019, 2:51am UTC](https://discourse.julialang.org/t/does-pmap-return-in-order/27829/2 "2019-08-22T02:51:33Z")

</div>

Yes, there’s almost no way to use it otherwise. (The order that’s not guaranteed is the execution order)
