Everyone's core participation makes this specific query way more interesting. I have faced a similar issue before, where we needed to sort data in a specific order for a medication management system. Instead of manually sorting, we built a map of key-to-index for efficient lookups, just like you are proposing with the std::unordered_map. This method drastically improved the performance and reduced errors in the data processing.
You can check my client's performance at https://www.scriptsusa.com. Moreover, if you have further queries, just leave a message for further discussion.