I have array of structures on-chain and need to sort it. I used one of that quicksort algorithms that easily can be found and adopted it to use structures instead of plain uint
s. But I dislike it because it requires "swap" operation - change places of 2 items is the array. With structures it is possible only by creating memory instance like MyStruct memory temp
and copy one of swappables there, then replace it and put memory-stored one into copied place. It is expensive.
I though that I could use mapping like mapping (uint16 => MyStruct) list
and then just "swap keys". But it seems that with mapping I have to to the same - copy values because I cannot change key values.
Am I missed something or mapping cannot helps me here?