Thank you very much. That problem was bothering me for quite a long time, but I couldn&#x27;t figure out correct term for googling.<p>Another solution I made myself is just to use string as a key. If you need to insert something between &quot;a&quot; and &quot;b&quot;, it&#x27;ll become &quot;an&quot;. If you need to insert something between &quot;an&quot; and &quot;am&quot;, it&#x27;ll become &quot;ann&quot;, etc. It uses 26 letters but probably should use 64 different characters. This way you&#x27;ll manipulate strings, they could be easily sorted and you&#x27;ll figure out next string quite fast. But they could grow long, so entire recalculation should be done from time to time.