code: def _sort(self, a, b):
          '''
          sort the headers according to rfc 2616 so when __iter__ is called, the accept media types are
          in order from most preferred to least preferred
          '''
          ret = 0
  
          # first we check q, higher values win:
          if a[1] != b[1]:
              ret = cmp(a[1], b[1])
          else:
              found = False
              for i in range(2):
                  ai = a[0][i]
                  bi = b[0][i]
                  if ai == '*':
                      if bi != '*':
                          ret = -1
                          found = True
                          break
                      else:
                          # both *, more verbose params win
                          ret = cmp(len(a[2]), len(b[2]))
                          found = True
                          break
                  elif bi == '*':
                      ret = 1
                      found = True
                      break
  
              if not found:
                  ret = cmp(len(a[2]), len(b[2]))
  
          return ref _sort(self, a, b):
          '''
          sort the headers according to rfc 2616 so when __iter__ is called, the accept media types are
          in order from most preferred to least preferred
          '''
          ret = 0
  
          # first we check q, higher values win:
          if a[1] != b[1]:
              ret = cmp(a[1], b[1])
          else:
              found = False
              for i in range(2):
                  ai = a[0][i]
                  bi = b[0][i]
                  if ai == '*':
                      if bi != '*':
                          ret = -1
                          found = True
                          break
                      else:
                          # both *, more verbose params win
                          ret = cmp(len(a[2]), len(b[2]))
                          found = True
                          break
                  elif bi == '*':
                      ret = 1
                      found = True
                      break
  
              if not found:
                  ret = cmp(len(a[2]), len(b[2]))
  
          return ret
docs: sort the headers according to rfc 2616 so when __iter__ is called, the accept media types are
          in order from most preferred to least preferred