View Single Post
  #5  
Old 01-11-2007, 12:21 AM
Tolnaftate2004 Tolnaftate2004 is offline
penguin.
Join Date: Jul 2004
Location: Berkeley, CA
Posts: 534
Tolnaftate2004 is a jewel in the roughTolnaftate2004 is a jewel in the rough
Send a message via AIM to Tolnaftate2004
Quote:
Originally Posted by Chompy View Post
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:
blah blah blah 
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.
__________________
◕‿‿◕ · pfa · check yer syntax! · src

Killa Be: when i got that locker in 6th grade the only thing in it was a picture of a midget useing a firehose :/
Reply With Quote