This is a short note on implementing the Bubble Sort algorithm on the AVR and Arduino microcontrollers. Bubble sort or sinking sort is one of the many sorting algorithms. In this algorithm, a list is repeatedly read where each line is compared to adjacent elements and swaps them if they are in the wrong order. The algorithm stops once all the elements in the list is sorted.
In the application note, the subroutine “bubble” sorts up to 224 bytes of SRAM data which is the SRAM area that can be reached by the lower eight bits of a pointer.
The flow-chart of the bubble sort algorithm is shown: