function algBubble(input:Array):Array{
var changed:Boolean=true;
while(changed==true){
changed=false;
for(var i:int=0; i<input.length-1; i++){
if(input[i]>input[i+1]){
var temp:int=input[i];
input[i]=input[i+1];
input[i+1]=temp;
changed==true;
}
}
}
return input;
}
It only seems to run through the array once, leaving it mostly unsorted.
I suggest you change:
to:
The first does a comparison and throws it away, the second actually sets
changedtotrueto indicate that a swap has been done.Other than that little problem, everything else looks fine.