# Reversing order of \`prod(itr)\`

**URL:** <https://discourse.julialang.org/t/reversing-order-of-prod-itr/51613>\
**Category:** General Usage\
**Created:** [December 10, 2020, 2:42pm UTC](https://discourse.julialang.org/t/reversing-order-of-prod-itr/51613 "2020-12-10T14:42:31Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [December 10, 2020, 7:59pm UTC](https://discourse.julialang.org/t/reversing-order-of-prod-itr/51613/7 "2020-12-10T19:59:42Z")

</div>

> [@jlbosse](#):
>
> because my iterator (a dict) happens to be ordered the way I want it.

You realize that you can’t rely on this? The ordering of a `Dict` may change unpredictably as you add elements, or if you update Julia to a new version. Don’t use `Dict` if you want a specific iteration order; use something else like the [`OrderedDict` type in the OrderedCollections.jl package](https://github.com/JuliaCollections/OrderedCollections.jl).

> [@jlbosse](#):
>
> ```julia
> str = ""
> for i in [1,2,3]
> str = str * "$i"
> end
> 
> ```

Don’t accumulate strings this way — every iteration of your loop allocates and copies into a new string. See this discussion: [Accumulating strings dynamically - #3 by stevengj](https://discourse.julialang.org/t/accumulating-strings-dynamically/51209/3)

---

_[View the full topic](https://discourse.julialang.org/t/reversing-order-of-prod-itr/51613)._
