31 #ifndef ACE_SORTING_BUBBLE_SORT_H
32 #define ACE_SORTING_BUBBLE_SORT_H
36 #if ! defined(ACE_SORTING_DIRECT_BUBBLE_SORT)
43 #define ACE_SORTING_DIRECT_BUBBLE_SORT 0
46 namespace ace_sorting {
54 #if ACE_SORTING_DIRECT_BUBBLE_SORT
56 void bubbleSort(T data[], uint16_t n) {
60 for (uint16_t i = 1; i < n; i++) {
61 if (data[i] < data[i - 1]) {
62 swap(data[i - 1], data[i]);
71 auto&& lessThan = [](
const T& a,
const T& b) ->
bool {
return a < b; };
83 template <
typename T,
typename F>
88 for (uint16_t i = 1; i < n; i++) {
89 if (lessThan(data[i], data[i - 1])) {
90 swap(data[i - 1], data[i]);