BubbleSort.borg

BubbleSort.borg


bubbleSort(table):: {
    lim:size(table);
    swap:true;
    for(i:1, (swap & (i1,
        {
        swap:=false;
        for(k:1, k<=(lim-i), k:=k+1,
            if(table[k]>table[k+1],
                {
                temp:table[k];
                table[k]:=table[k+1];
                table[k+1]:=temp;
                swap:=true    
                }
            )
        )
        } 
    );
    table
}