I am looking for material covering this idea:
Given a list-like data structure (e.g. database table) a sortKey property (column) should be introduced that
- reflects the desired sort order (ORDER BY sortKey)
- is unique within the list
- makes insertions at any position in the (sorted) list possible
- is immutable
Requirements 1-3 can be achieved with a integer sortKey, where with each insertion, all elements get potentially assigned a new sortKey.
Requirements 1-4 could be achieved with a tree'ish sortKey, e.g. a decimal type range (0.0, 1.0); each insertion would read the sortKey for its predecessor and successor and use sortKey(newItem) = ( sortKey(left) + sortKey(right) ) / 2
Is there a common term for this problem/solution, that I can lookup or can someone please point me to literatur.
Thanks!