code: def letter_scales(counts):
      try:
          scale = 1.0 / sum(counts.values())
      except ZeroDivisionError:
          return []
      freqs = [(aa, cnt*scale) for aa, cnt in counts.iteritems() if cnt]
      freqs.sort(key=lambda pair: pair[1])
      return freqs