How to handle sorting when Saving/loading levels with an array?
Wanting to rethink how i save and load my levels and I need some inspiration and help.
Currently I have one game frame where all my code is and it loads the levels from an array on start, regular one frame method.
I have a separate project where i build the levels in frames and and then save it to a master array file. Each level gets an ID and that ID becomes a Z-index in the array.
I have a level select that loops through the array and looks how many Z-indexes it has and creates buttons for each of them.
My issue is when I want to e.g. reorder two levels or for instance inject a level between the existing ones, it shifts all the IDs and I have no smooth way to do that other than manually changing the index and resaving the array for every affected frame.
E.g. i have 10 levels, but i want to insert a level between 6 and 7. So i have to change the id of level 7, 8, 9 and 10.
Does anyone have any suggestion on what to do?