title: Haskell merge sort implementation
body: <p>I am trying to solve this question:
  Define a recursive function msort :: Ord a => [a] -> [a] that imple-
  ments merge sort, which can be specified by the following two rules:
   Lists of length  1 are already sorted;
   Other lists can be sorted by sorting the two halves and merging the
  resulting lists.</p>
  
  <p>But I am having a hard time understanding how exactly the code of merge sort work.</p>
  
  <p>here is my code ::</p>
  
  <pre><code>merge :: Ord a =&gt; [a] -&gt; [a] -&gt; [a]
  merge [] [] = []
  merge (x:xs) (y:ys) | y &gt; x =  (x:xs) ++  (y:ys)
                      |otherwise =  (y:ys) ++  (x:xs)
  
  
  msort :: Ord a =&gt; [a] -&gt; [a]
  --base case , if length less than or equal 1 , then list is already  sorted
  msort [] = [] -- how to implement base case?
  msort (x:xs)  = merge  (take (length(x:xs) `div` 2 ) (x:xs)) (drop (length(x:xs) `div` 2 ) (x:xs))
  </code></pre>