Question: invalid subscript selector

balle := proc (L) local K, a, i, c, J;
J := L;
 c := nops(J);
 while J <> K do
K := J;
for i from 0 to c-1 do
if J[i+1] < J[i] then
a := J[i]; J[i] := J[i+1]; J[i+1] := a
end if
end do
end do;
return J
end proc

I got the error "Error, (in balle) invalid subscript selector " even if L is a list. I don't understand. Could you help me, pretty please? 

Please Wait...