09.05.2012, 10:06
You could try this out...took me a minute to write it out (with testing and all lol)
EDIT: this is what i used to test it
pawn Код:
stock BubbleSort(Array[], size) //at least similar
{
new tmpslot=0, bool:swapped;
redo:
swapped = false;
for(new index=1; index < size; index++)
{
if(Array[index-1] > Array[index])
{
tmpslot = Array[index];
Array[index] = Array[index-1];
Array[index-1] = tmpslot;
swapped = true;
}
}
if(swapped) goto redo;
for(new index=0; index < size; index++) printf("Number %d: %d", index+1, Array[index]);
}
pawn Код:
new TestArray[10] = {4,3,6,2,7,1,5,9,8,10};
main()
{
BubbleSort(TestArray, 10);
}