--- /dev/null
+#include <stdio.h>
+#include <stdbool.h>
+
+void swap(int* v1, int* v2) {
+ int tempValue = *v1;
+ *v1 = *v2;
+ *v2 = tempValue;
+}
+
+/** Display the array on standard output. */
+void displayArray(int* array, int count) {
+ for (int tabIndex = 0; tabIndex < count; ++tabIndex) {
+ printf("array[%d] = %d\n", tabIndex, array[tabIndex]);
+ }
+}
+
+/** Perform one swap on the first two values not in increasing order.
+ *
+ * @return true if a swap was performed, false if the whole array is ordered.
+ */
+bool sortFirst(int* array, int length) {
+ for (int tabIndex = 0; tabIndex < (length - 1); ++tabIndex) {
+ if (array[tabIndex] > array[tabIndex + 1]) {
+ swap(&array[tabIndex], &array[tabIndex + 1]);
+ return true;
+ }
+ }
+
+ return false;
+}
+
+void sortArray(int* array, int length) {
+ bool swappedValues;
+
+ do {
+ swappedValues = sortFirst(array, length);
+ } while (swappedValues);
+}
+
+int main() {
+ int arr[10] = {23, 2, 0, 4, 56, 3, 7, 8, 98, 1};
+ sortArray(arr, 10);
+ displayArray(arr, 10);
+}