Sorting values
#1

I have these values:
pawn Код:
new
  Values[2][5] =
  {
    {45, 88, 01, 94, 3},
    {0, 0, 0, 0, 0}
  };
How can I sort them (1, 3, 45, 88, 94) and place them into "Values[1]"?
Reply
#2

pawn Код:
bubbleSort(array[])
{
    new i,j;
    int length = sizeof(array[]);
    for(i=0;i<length;i++)
    {
        for(j=0;j<i;j++)
        {
            if(array[i]>array[j])
            {
                new temp=array[i];
                array[i]=array[j];
                array[j]=temp;
            }

        }

    }

}
//this will sort from greates till smallest

new
  Values[2][5] =
  {
    {45, 88, 01, 94, 3},
    {0, 0, 0, 0, 0}
  };
bubbleSort(Values[0]);
for(new i = 0; i < 5; i++) Values[1][i] = Values[0][4-i];
Reply
#3

Quote:
Originally Posted by dice7
pawn Код:
int length = sizeof(array[]);
Lmao, can you show me how to use that?
Reply
#4

i meant
pawn Код:
new length
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)