=={{header|Elixir}}==
<lang elixir>defmodule Sort do
defmodule Sort do
def bubble_sort(list) when length(list)<=1, do: list ▼
def bubble_sortbsort(list) when is_listlength(list) <= 1, do: bubble_sort(list, [])
▲ def bubble_sortbsort(list) when lengthis_list(list) <=1, do : list
t = bsort_move(list)
def bubble_sort([x], sorted), do: [x | sorted]
def bubble_sort(list, sorted) do
if t == list do t else bsort(t) end
{rest, [max]} = Enum.split(bubble_move(list), -1)
bubble_sort(rest, [max | sorted])
end
def bubble_movebsort_move([x, y | t]) when x > y, do: [y | bsort_move([x | t])]
def bubble_movebsort_move([x, y | t]) when x > y, do: [yx | bubble_movebsort_move([xy | t])]
def bsort_move(list), do: list
def bubble_move([x, y | t]) , do: [x | bubble_move([y | t])]
end
IO.inspect Sort.bubble_sort([3,2,1,4,5,2])</lang>
{{out}}
<pre>
[1, 2, 2, 3, 4, 5]
=={{header|Erlang}}==
|