Bubble Sorting with a Arduino/C++ Application

One of the first things to learn in programming is how to sort numbers. It is an easy task in most high-level programming languages as functions exist to do this. But how do they work? What if you’re working with a platform that doesn’t have such functions? We can sort an array of integers with what’s known a the Bubble Sort Algorithm.

Bubble sort, sometimes referred to as sinking sort, is a simple sorting algorithm that repeatedly steps through the list to be sorted, compares each pair of adjacent items and swaps them if they are in the wrong order.

Below is code that is designed to work on an Arduino, it will sort an array of integers. Note that this isn’t the fastest way to sort data, especially large amounts of it. But it does work quite effectively.