I've written the short listing below for the BBC A/B micro to illustrate in the most graphic way I could think of how a bubble sort works.
The contents of a selected part of the screen memory is sorted, enabling memory exchanges to be viewed as they happen. While the space bar is pressed the delay routine is bypassed.
The user could experiment by including teletext control characters (shift function keys, OS 1.2) as well as upper/lower case letters and numerals.
10 MODE 7:*KEY0 RUN|M
20 VDU23,1,0;0;0;0;
30 REM BY H M HOFFMAN
40 PRINTTAB(5,3)CHR$130;"IN-MEMORY BUBBLE SORT"
50 ON ERROR REPORT:PRINT" in line ";ERL:END
60 INPUTTAB(0,5)"Enter a message"A$
70 PRINTTAB(5,18)CHR$131;"Press SPACE for full speed."
80 PRINTTAB(5,20)CHR$129;"Press f0 to rerun"
90 PRINTTAB(0,5)STRING$(70," ")
100 M=&7DE0
110 FOR char=1 TO LENA$
120 ?(M+2*char-1)=ASCMID$(A$,char,1)
130 NEXTchar
140 swap=FALSE
150 FOR L=M TO M+2*char
160 IF ?L>?(L+1) PROCswap
170 NEXT L
180 IF swap = TRUE THEN 140:REM repeat until sorted
190 END
200 :::
210 DEFPROCswap
220 swap = TRUE
230 M%=?L
240 ?L=?(L+1):?(L+1)=M%
250 IF NOT INKEY(-99) PROCdelay
260 ENDPROC
270 :::
280 DEFPROCdelay
290 TIME=0:REPEAT UNTIL TIME =30
300 ENDPROC
Would this reader please send in their address as the original letter has gone missing?