1

Does the association <|a -> 1, b -> 2, c -> 3|> in Mathematica have order or not? If I iterate the association multiple times, is it guaranteed that the items will be iterated in the same order?

kirma
  • 19,056
  • 1
  • 51
  • 93
m00nlight
  • 1,582
  • 1
  • 12
  • 22
  • 1
    I have not used association much, but for me, it makes little sense to talk about "order" of keys. The point is that one gives a key, and gets the value associated with that key by a lookup. Like a hash table. If you depend on an "order" of keys in the lookup table to do something, then I think you are doing something wrong. – Nasser Apr 05 '15 at 07:53
  • @Nasser: It's not the most frequent use case, but sometimes you want to aggregate data in an Association, then later process the key/value pairs in the order they were discovered. And I often find it handy that BarChart, ListPlot&friends don't jumble association data I pass them. So I'm glad Wolfram made them ordered. – Niki Estner Apr 05 '15 at 11:35
  • @nikie Thanks for clarification :) – m00nlight Apr 06 '15 at 12:31

0 Answers0