Sorting values - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Sorting values (
/showthread.php?tid=135437)
Sorting values -
Miguel - 20.03.2010
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]"?
Re: Sorting values -
dice7 - 20.03.2010
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];
Re: Sorting values -
Miguel - 20.03.2010
Quote:
Originally Posted by dice7
pawn Код:
int length = sizeof(array[]);
|
Lmao, can you show me how to use that?
Re: Sorting values -
dice7 - 20.03.2010
i meant