Bubble sort implementation, slightly modificated to be more compatible
with Haskell.