-->
Tri à bulles
Xmin=0
Xmax=50
Ymin=0
Ymax=100
T = [100,53,77,12,5,148,11,34,86,17,98,3,50,53,0,28,94,51,48,25,6,54,61,60,78,99,12,41,33,47,54,8,5,47,26,58,11,31,54,37,82,47,42,25,18,26,12,43,68,71]
i = T.length
j = 0
trace(T)
transparence = 1
bubble(T,i,j)
function bubble(T,i,j){
if(i > 0){
if(j < i-1){
inverse(T,j)
setTimeout(function (){bubble(T,i,j+1)},50)
}
else{
j=0
setTimeout(function (){bubble(T,i-1,j)},50)
}
}
trace(T)
}
function inverse(T,j){
if( T[j] > T[j+1] ){
x = T[j]
T[j] = T[j+1]
T[j+1] = x
}
}
function trace(T){
couleur = blanc
peinture = blanc
transparence = 1
rectangle([0,100],50,100)
couleur = noir
for(i=0;i < T.length;i++){
peinture = bleu
transparence = 0.5
rectangle([i,T[i]],1,T[i])
}
}