lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Thu, Aug 27, 2015 at 8:55 AM, Coda Highland <chighland@gmail.com> wrote:
> Bubble sort, on the other hand, is especially vulnerable to bad
> comparators, because it tries to sort the entire array on every pass.

Bubble sort can be trivially improved to walk over one less element on
each successive pass, guaranteeing termination (unless the compare
function itself never returns).

https://en.wikipedia.org/wiki/Bubblesort#Optimizing_bubble_sort

-Parke