SA-MP Forums Archive
BubbleSort with 2 dimensional - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: BubbleSort with 2 dimensional (/showthread.php?tid=471375)



BubbleSort with 2 dimensional - kizla - 22.10.2013

soo i have a problem with BubbleSort method, it works great while i have a 1 dimensional array, but what when i have 2 dimensional? example: "PlayerInfo[playerid][Kills]" how to sort it by order?

Here i have some example which i use for 1 dimensional:

pawn Код:
//Credits iPS Bruno
BubbleSort(Array[], iSize)
{
    new
        iLoop       = 0x0,
        iCircuito   = 0x0,
        iTemp       = 0x0;
       
    while(++iLoop < iSize)
    {
        iCircuito = (-1);
        while(++iCircuito < iLoop)
        iTemp =
                ((Array[iLoop]  >  Array[iCircuito] ) ? ( iTemp = Array[iLoop], Array[iLoop] = Array[iCircuito], Array[iCircuito] = iTemp) : (0x0));
    }
    return Array;
}