Apply bubble sort algorithm (#736)