void BubbleSort(int a[], int n)
{
int i, j;// needed for the loops
int tmp;// needed for swapping values between two variables
if (n <= 1) return;// check if the array has no elements or has 1 element
// in that case there is no need of sorting
i = 1;// initializing the variable i
do// the start of a do/while loop
{
for (j = n - 1; j >= i; --j)// for loop that goes backwards and compares
{
if (a[j-1] > a[j])// if the condition is met then swap
{
tmp = a[j-1];
a[j-1] = a[j];
a[j] = tmp;
}
}
} while (++i < n);
}