title: Erlang Bubble sort
body: <p>I'm learning Erlang and decided to implement bubble sort in it, it took me some effort and in result i've succeded, but i see that my way of thinking is incorrect, is there more effecient way to implement it or not?</p>
  
  <pre><code>bubble_sort(L) -&gt;
  if 
  length(L) &gt; 1 -&gt;
      SL=bubble_sort_p(L),
      bubble_sort(lists:sublist(SL,1,length(SL)-1)) ++ [lists:last(SL)];
  true -&gt; L
  end.
  
  bubble_sort_p([]) -&gt; [];    
  bubble_sort_p([F | R]) -&gt;
      case length(R) &gt; 0 of
          true -&gt; case F &gt; hd(R) of
                  true -&gt;  [hd(R)] ++ bubble_sort_p([F|tl(R)]);
                  false -&gt; [F] ++ bubble_sort_p([hd(R)|tl(R)])
              end;
          false -&gt; [F]
      end.
  </code></pre>