title: Sorting a list based on the 2nd key
body: <p>I need help in sorting a list with 2 keys inside. For example, if I input "google" the output should be like this:</p>
  
  <pre><code>Letter: 'g', Frequency: 2
  Letter: 'o', Frequency: 2
  Letter: 'e', Frequency: 1
  Letter: 'l', Frequency: 1
  </code></pre>
  
  <p>But instead, what I get is this:</p>
  
  <pre><code>Letter: 'e', Frequency: 1
  Letter: 'g', Frequency: 2
  Letter: 'l', Frequency: 1
  Letter: 'o', Frequency: 2
  </code></pre>
  
  <p>Basically it just sorts the letters and not the frequency. What I wanted was for it to be sorted by Frequency first then by Letter. Here is my code snippet for the sorting part and a dictionary sample declaration:</p>
  
  <pre><code>adict = {'Letter':'a', 'Frequency':0}
  bdict = {'Letter':'b', 'Frequency':0}
  cdict = {'Letter':'c', 'Frequency':0}
  
  def getKey(item):
      return item['Frequency']
  
  finalArr = sorted(newArr, key = getKey)
  </code></pre>
  
  <p>I've tried the lambda sorting and the itemgetter but it still sorts the letter.</p>
  
  <p>Here's the Frequency updating part (not the whole part just a sample):</p>
  
  <pre><code>for ex in range(0, len(temp)):
      if temp[count] == 'a': adict['Frequency']+=1
      elif temp[count] == 'b': bdict['Frequency']+=1
      elif temp[count] == 'c': cdict['Frequency']+=1
  </code></pre>
  
  <p>And here's if the Frequency is not 0 it will be assigned to a list:</p>
  
  <pre><code>if adict['Frequency'] != 0 : newArr.append(adict) 
  if bdict['Frequency'] != 0 : newArr.append(bdict)
  if cdict['Frequency'] != 0 : newArr.append(cdict)
  </code></pre>