So lists might seem complicated at first, because of having to learn new commands to deal with them, but in reality they are very simple. Just think of a literal list in real life. Let's say you have a list with 5 points on it:
1. A
2. B
3. C
4. D
5. E
You want to find wherever D is in the list and move it to the top spot. The steps you would take as a human (often unconsciously) are:
Scan the list to find which position has D in it.
You've found D and it's at the 4th slot.
Keep in your memory that the data you are moving is D.
Erase position 4 with your eraser.
Write D at the top of the list and give it the position 1.
Rewrite all the other position numbers accordingly.
When you're dealing with that in code some of those steps you have to do and some the computer will do for you. Specifically the rewriting of the positions, the last step above, will be done automatically by the computer, but the rest of the steps you have to do yourself.
So, based off your updated code posted on Saturday, you already have the instance you want stored in the _inst variable before you need to rearrange the list. So let's have a look at the problem code:
Code:
var _firstElement = ds_list_find_value(global.characters, 0);
var _instPosition = ds_list_find_index(global.characters, _inst);
ds_list_set(global.characters, 0, _inst);
ds_list_set(global.characters, _instPosition, _firstElement);
First of all, you don't need to know what's in the first place, so there's no need for this line
var _firstElement = ds_list_find_value(global.characters, 0);
(remember none of the steps that I wrote out that you would take as a human involves finding what value is in the first position). So let's go ahead and rewrite that block so it functions properly:
Code:
var _instPosition = ds_list_find_index(global.characters, _inst);
ds_list_delete(global.characters,_instPosition); // First we delete the position that holds the _inst value, we do this first because if we insert the position first, the list order will change and _instPosition will no longer point to the correct position
ds_list_insert(global.characters, 0, _inst); // Then we use the ds_list_insert() function to place a value at a position, not ds_list_set as ds_list_set will overwrite whatever is stored in position 0 currently
And that should be it. When you're dealing with these things in the future, make sure to read through the manual and ALL the entries that are involved with whatever you are dealing with. Looking just at ds_list_set() would not yield the answers you need, but looking at the ds_lists page and reading each function listed there, you should be able to, with a bit of experimentation and some time thinking, figure out what the functions you need to use are. Then it's just a matter of using code logic in your head to place them in the correct positions.