title: In python, how to sort list by frequency of elements
body: <p>I have a list of elements: <code>[ 3, 3, 6, 6, 6, 5, 5, 8 ]</code> and need to sort it by the frequency of elements to get this: <code>[ 6, 6, 6, 3, 3, 5, 5, 8 ]</code> of several elements have the same frequency sort them by value. Can you find any shorter way than this?</p>
  
  <pre><code>import collections
  from operator import itemgetter, attrgetter
  
  def freq_sort(arr):
      counter=collections.Counter(arr)
      com = sorted(counter.most_common(), key=itemgetter(1,0), reverse=True)
      com = map(lambda x: [x[0]] * x[1], com)
      return [item for sublist in com for item in sublist]
  </code></pre>