Here is a link to some sorting algorithms. They are in java, but easy to convert to BMax. Each has an example on th epage that shows how it works.
http://www.cs.ubc.ca/spider/harrison/Java/sorting-demo.html
http://www.cs.ubc.ca/spider/harrison/Java/sorting-demo.html