Quote:
Originally Posted by Chompy
Both examples are almost the same,
' if (array[b+1] < array[b]) ' is only changing
Nice script tho Gambet
Here is maybe how I would do it
|
PHP Code:
//#CLIENTSIDE
function onCreated(){
temp.example = {1,6,4,2, 5,8,20,100,54,1000,523};
doFunction("GreatestToLast", temp.example);
}
function doFunction(mode, array) {
temp.s = (mode=="GreatestToLast"? 1:(mode=="LeastToGreatest"? -1:0));
temp.len = temp.array.size();
for (temp.a = 0; temp.a < temp.len - 1; temp.a ++) {
for (temp.b = 0; temp.b < temp.len - 1 - temp.a; temp.b ++) {
if (temp.s*temp.array[temp.b + 1] > temp.s*temp.array[temp. b]) {
this.temp = temp.array[temp.b];
temp.array[temp.b] = temp.array[temp.b + 1];
temp.array[temp.b + 1] = this.temp;
this.results = temp.array;
player.chat = this.results;
}
}
}
}
}
Or something of the sort.