How to get an array of clojure arrays to maintain insertion order after join?

I have an array-map which assoc I entered into it some values. After a certain size, the value of PersistentHashMap returned, not the original PersistentArrayMap . I read about this behavior on several websites. Is there a way to force the insertion order even after assoc ?

I have a separate function that will take the ash-map and key vector and return a β€œfresh” array-map with the keys in that order, but this means that for each associated object I need to extract the keys first, cons / conj a new key to the vector and then create a new array map. It seems kludgey, even if it is written in a separate function.

Is there a more direct way to maintain insertion order even with large arrays (> 10, but? 50)?

In case that matters, I use a list of map arrays as data in an incanter dataset, and then output excel. The save-xls function preserves the order of keys / columns.

thanks

+6
source share
1 answer

You can use an ordered map: https://github.com/flatland/ordered

+9
source

Source: https://habr.com/ru/post/923266/


All Articles