Moving elements in lists

Just to be clear, in the above example with observing an array, is that needed even for the case of moving only within a single array? (Not maps of arrays like the original question)

One idea I was playing around with is representing the array as a map, and having a sortIndex property on each element. Figma had an interesting blogpost on how they handle reordering of layers (this exact issue) - and they’re using fractional indexing (using the string versions of this to avoid needing bignum)

Then I have a utility function to convert this map to a standard, sorted array.

Would that work for this case? It should at least avoid data inconsistencies, since re-ordering is just setting a map value.