title: Prioritize values of a list in python
body: <p>I get a list of values from the following query set,</p>
  
  <pre><code> s_v = SiverifyVerificationSite.objects.filter(pattern_id=int(p_id), if_target=bundle.obj.pattern.if_target).values_list('create_status', flat=True)
      print 'svid', s_v
  </code></pre>
  
  <p>This query set runs for many a times and it returns a list of values. For eg., the o/p for the above print statement on a single occasion of query set run is, </p>
  
  <pre><code>svid [1L, 1L],
  svid [6L, 8L],
  svid [1L, 6L, 1L, 1L],
  svid [1L, 6L, 1L]
  </code></pre>
  
  <p>The range of values in the list would be from 0L to 8L. I now need to prioritize the values I get in the list. 
  The highest priority in my case is for 8L. So, if 8L exists in the list I need to carry out an operation. The second priority is for 6L. If both 8L and 6L exists in the same list, the priority is for 8L. What is the best way to do this. I tried loop statements but this seems to be a complex sort. </p>
  
  <p>Tried code:</p>
  
  <pre><code>def dehydrate_orc_display(self, bundle):
  
          final_data = {}
  
          p_id = ''.join(x for x in bundle.obj.pdb_pid if x.isdigit())
          # print 'vioid', bundle.obj.pdb_id
          s_verify = SiverifyVerificationSite.objects.filter(pdb_id=bundle.obj.pdb_id, pattern_id=int(p_id), if_target=bundle.obj.pattern.if_target)
          s_v = SiverifyVerificationSite.objects.filter(pattern_id=int(p_id), if_target=bundle.obj.pattern.if_target).values_list('create_status', flat=True)
          print 'svid', s_v
          print 'fields', s_verify        
          if 8L in s_v:
                final_data['create_status'] = 8
          if 6L in s_v:
                final_data['create_status'] = 6
          if 8L and 6L in s_v:
                final_data['create_status'] = 8
          return final_data
  </code></pre>