title: How to order choices based on their name instead of their index?
body: <p>This is my first post on stackoverflow, I'm going to try to follow the basic rules but be gentle with me.</p>
  
  <p>I have to make a few changes (which appeared superficial at first glance) to a django app.
  The client wants all the dropdown menus of the forms in the admin part of the site to be sorted alphabetically. The problem is that some of these choices are based on static lists defined in the models.py files like this one :  </p>
  
  <pre><code>STATE=(  
      (1, 'Full'),  
      (2, 'Damaged'),  
      (3, 'Partially damaged')  
  )  
  </code></pre>
  
  <p>I tried to reorder the list like that :  </p>
  
  <pre><code>STATE=(  
      (2, 'Damaged'),  
      (1, 'Full'),  
      (3, 'Partially damaged')  
  )  
  </code></pre>
  
  <p>but it doesn't seem to make a difference (although I'm not really familiar with the way Python caches classes and views).</p>
  
  <p>Reordering the indexes like that :  </p>
  
  <pre><code>STATE=(  
      (1, 'Damaged'),  
      (2, 'Full'),  
      (3, 'Partially damaged')  
  )  
  </code></pre>
  
  <p>works but would mean writing some huge and complicated SQL scripts to keep the old data consistent (since most of the lists are longer than this one and permutations would become more complex).</p>
  
  <p>So my question is : Is there a way to sort these choices based on their name instead of the index ? Maybe in the definition of the <code>models.IntegerField(..., choices=STATE)</code> ?</p>
  
  <p>Thank you all.</p>