def _sortKeywords(keyword, kwds):
 sm = SequenceMatcher()
 sm.set_seq1(keyword.lower())
 ratios = [(ratcliff(keyword, k, sm), k) for k in kwds]
 checkContained = False
 if (len(keyword) > 4):
  checkContained = True
 for (idx, data) in enumerate(ratios):
  (ratio, key) = data
  if key.startswith(keyword):
   ratios[idx] = ((ratio + 0.5), key)
  elif (checkContained and (keyword in key)):
   ratios[idx] = ((ratio + 0.3), key)
 ratios.sort()
 ratios.reverse()
 return [r[1] for r in ratios]

def _sortKeywords ( keyword , kwds ) : sm = SequenceMatcher ( ) sm . set_seq1 ( keyword . lower ( ) ) ratios = [ ( ratcliff ( keyword , k , sm ) , k ) for k in kwds ] checkContained = False if ( len ( keyword ) > 4 ) : checkContained = True for ( idx , data ) in enumerate ( ratios ) : ( ratio , key ) = data if key . startswith ( keyword ) : ratios [ idx ] = ( ( ratio + 0.5 ) , key ) elif ( checkContained and ( keyword in key ) ) : ratios [ idx ] = ( ( ratio + 0.3 ) , key ) ratios . sort ( ) ratios . reverse ( ) return [ r [ 1 ] for r in ratios ]
sort a list of keywords .