Sorting/Looping examples?

Hi guys,
I am at the stage of my game where I need to sort 10 numbers (can be reals or integers) from lowest to highest. Is there some way of looping (I'm thinking I can just create another attribute called 'x' and add 1 to 'x' after each cycle until 'x' reaches a certain number?). Has anyone got any examples of how they have done this in GS?
Failing that, (should always ask the easier option first!) is there a function built in that will automatically sort a set of numbers?
I can sort of see how this would/could work (well the loop anyway) but would be curious on seeing how others have done it.
Thanks,
Sam
I am at the stage of my game where I need to sort 10 numbers (can be reals or integers) from lowest to highest. Is there some way of looping (I'm thinking I can just create another attribute called 'x' and add 1 to 'x' after each cycle until 'x' reaches a certain number?). Has anyone got any examples of how they have done this in GS?
Failing that, (should always ask the easier option first!) is there a function built in that will automatically sort a set of numbers?
I can sort of see how this would/could work (well the loop anyway) but would be curious on seeing how others have done it.
Thanks,
Sam
Comments
Thanks,
Sam
The timer method is a neat way to loop through some iterations at a given time tick mark and you can stop, as I stated, upon a condition being met like in the other style ORBZ mentions and I mention in my previous paragraph.
Sorry, it sounded like you had the first method down. I was throwing out another. Didn't mean to confuse.
its been a long time since I first asked this, but I am back to the same point again. I have 10 attributes (reals) that I need to sort into other attributes based on how big they are. Has anyone got a bit of example code they could show me on how to do this?
Your help greatly appreciated!
Sam
while (game.i <= 10)
{
if(game.racer[game.i] > game.temptime)
{
game.temptime = global.racer[game.i,];
game.tempracernumber = game.i;
}
global.i = global.i + 1;
}
is this possible via a relatively simple method in GS?
Sam