Bubble Sort + enum
#5

Thank you, I already knew how to write:
pawn Код:
#include <a_samp>

enum eLIST_INFO
{
    l_int,
    l_str[10],
    Float:l_float
}
new List[][eLIST_INFO] = {
    {2,"Test2",2.2},
    {1,"Test1",1.1},
    {4,"Test4",4.4},
    {3,"Test3",3.3},
    {5,"Test5",5.5}
};

stock BubbleSort(array[][],index = 0,start = 0,len = sizeof(array),len2 = sizeof(array[]))
{
    for(new i=start;i<len-1+start;i++)
    {
        for(new j=start;j<len-1-i+start;j++)
        {
            if(array[j+1][index] < array[j][index])
            {
                for(new t;t<len2;t++)
                {
                    new temp = array[j+1][t];
                    array[j+1][t] = array[j][t];
                    array[j][t] = temp;
                }
            }
        }
    }
    return 1;
}

public OnFilterScriptInit()
{
    BubbleSort(List,l_int);
    for(new i;i<sizeof(List);i++) printf("%d %s %.f",List[i][l_int],List[i][l_str],List[i][l_float]);
    return 1;
}
It works !
Thanks a lot !
Reply


Messages In This Thread
Bubble Sort + enum - by ATomas - 14.03.2014, 13:45
AW: Bubble Sort + enum - by Nero_3D - 14.03.2014, 16:53
Re: Bubble Sort + enum - by ATomas - 14.03.2014, 19:36
AW: Bubble Sort + enum - by Nero_3D - 14.03.2014, 20:41
Re: Bubble Sort + enum - by ATomas - 14.03.2014, 21:56

Forum Jump:


Users browsing this thread: 1 Guest(s)