title: sorting a list of strings by their length not working
body: <p>I was wondering why my lists of strings are not sorting properly. I type in a 4 word sentence then it is permuted 24 times and then I want it to sort those sentences. Except when I use</p>
  
  <pre><code>def my4sort(alist): #sorts the list of strings
    return(sorted(alist, key=len))
  </code></pre>
  
  <blockquote>
    <p>Permutation 0: ' bob is programming lots ' when sorted gives ' bob is programming lots '</p>
    
    <p>Permutation 1: ' bob is lots programming ' when sorted gives ' bob is lots programming '</p>
    
    <p>Permutation 2: ' bob programming is lots ' when sorted gives ' bob programming is lots '</p>
    
    <p>Permutation 3: ' bob programming lots is ' when sorted gives ' bob programming lots is '</p>
    
    <p>Permutation 4: ' bob lots is programming ' when sorted gives ' bob lots is programming '</p>
    
    <p>Permutation 5: ' bob lots programming is ' when sorted gives ' bob lots programming is '</p>
    
    <p>Permutation 6: ' is bob programming lots ' when sorted gives ' is bob programming lots '</p>
    
    <p>Permutation 7: ' is bob lots programming ' when sorted gives ' is bob lots programming '</p>
    
    <p>Permutation 8: ' is programming bob lots ' when sorted gives ' is programming bob lots '</p>
    
    <p>Permutation 9: ' is programming lots bob ' when sorted gives ' is programming lots bob '</p>
    
    <p>Permutation 10: ' is lots bob programming ' when sorted gives ' is lots bob programming '</p>
  </blockquote>
  
  <p>This is the output I am getting, which you can see isn't right</p>
  
  <p>here is my permutation code</p>
  
  <pre><code>def permutations(liststring): #permutes the list of strings
      if not liststring:
          return ['']
      ret = []
      for i, d in enumerate(liststring):
          perms = permutations(liststring[:i] + liststring[i+1:])
          for perm in perms:
              ret.append(d + ' ' + perm)      
      return ret
  </code></pre>