#!/usr/bin/env mwnci function bsort(S=[]) { if (len(S) <= 1) { return S; } i=0 i_end=len(S)-1 while (i < i_end) { j=0 j_end=len(S)-i j_end-- while (j < j_end) { if (S[j] > S[j+1]) { S=swap(S, j, j+1) } j++ } i++ } return S; } a=[] foreach n in 1..100 { a=push(a, random(10)) } println("Unsorted: ", a) a=bsort(a) println("Sorted: ", a)