title: Specific algorithm sorting n elements with m distinct values
body: <p>I am going through exercies for an exam in algorithm analysis and this is one of them:</p>
  
  <blockquote>
    <p>Present an algorithm that takes as input a list of n elements (that
    are comparable) and sorts them in O(n log m) time, where m is the
    number of distinct values in the input list.</p>
  </blockquote>
  
  <p>I have read about the common sorting algorithms and I really can't come up with a solution.</p>
  
  <p>Thanks for your help</p>