local bubble_sort = Future:new() function bubble_sort:poll(array) local n = array:size() self.state[n] = self.state[n] or n if n == 0 then return false end local swapped = false for i = 1, n - 1 do if array.at(i-1) > array.at(i) then array.swap(i-1, i) swapped = true end end self.state.n = self.state.n - 1 return not swapped end function make_available(sorter_list) table.insert(sorter_list, "bubble_sort") end