Getting lowest number and storing it in a variable

I have a set of 8 numbers..
I need to get the lowest and store it into a variable.. lets call it first.
After that I need to get the second lowest and store that into another variable.. lets call it second..
I need to do it again and again for 8 variables..

Lowest = variable: first
2nd Lowest = variable: second
3rd Lowest = variable: third
4th Lowest = variable: fourth
5th Lowest = variable: fifth
6th Lowest = variable: sixth
7th Lowest = variable: seventh
8th Lowest = variable: eighth
Like that.. I could mess around and do it myself but if someone here could write it out pretty quickly that would save me alot of time..

I wondered about the same issue, solving this would be awesome !

What variables do you want to order?

Originally Posted by MP2
View Post
What variables do you want to order?
Well I have this (new Fastest[8])
In those are times stored in MS.

What I need to do is get those MS and see which is lowest..
So that I can sort out the times in 1st, 2nd, 3rd, 4th, 5th, 6th, 7th and 8th.

Will write when I get home. Not attempting on iPhone.

Apologies in advance for when I forget.

Lol alright then

Can't be bothered sorry, but here's my code for getting the closest player, it may be of some use:

pawn Code:
new Float:dist = FLOAT_INFINITY, closest_player = playerid;
        new Float:pos[3], Float:this_dist;
        foreach(new i : Player)
            if(i == playerid) continue;
            GetPlayerPos(i, pos[0], pos[1], pos[2]);
            this_dist = GetPlayerDistanceFromPoint(playerid, pos[0], pos[1], pos[2]);
            if(this_dist < dist)
                closest_player = i;
                dist = this_dist;

Y_Less suggested that I sort the array..
But that wouldnt work, as I have also have another array with names..
So the names and times would need to be linked, while showing in order from fastest to slowest

Show full example what You exactly want

Originally Posted by Y_Less
View Post
I don't see the problem there at all, why can't you link data and sort the array? YSI has a set of functions in y_bintree for exactly that.
Because I don't know how to do that efficiently :P

Forum Jump:

Users browsing this thread: 1 Guest(s)