0

IterableStorageMap doesn't support ordering. How to sort the values of IterableStorageMap in ascending or descending order?

https://substrate.dev/rustdocs/v2.0.0/frame_support/storage/trait.IterableStorageMap.html

Amiya Behera
  • 2,210
  • 19
  • 32
  • For small storage maps you could collect into a vec and then sort. My recommendation would be to insert items in the right order or not rely on ordering, though. – apopiak Jan 06 '21 at 13:43
  • 1
    If you want to maintain a sorted data structure, a map seems like a weird choice. I agree with @apopiak that you should use a vector and maintain it in sorted order. This Recipe may offer some inspiration https://substrate.dev/recipes/vec-set.html – Dan Forbes Jan 06 '21 at 15:38
  • Ya got it. "To ensure reasonable performance, we will enforce that the Vec always remains sorted" – Amiya Behera Jan 06 '21 at 15:57

0 Answers0