def sortAKAsBySimilarity(movie, title, _titlesOnly=True, _preferredLang=None):
 language = movie.guessLanguage()
 m_title = movie['title'].lower()
 l_title = title.lower()
 if isinstance(l_title, unicode):
  l_title = l_title.encode('utf8')
 scores = []
 score = difflib.SequenceMatcher(None, m_title.encode('utf8'), l_title).ratio()
 scores.append((score, movie['title'], None))
 for (language, aka) in akasLanguages(movie):
  m_title = aka.lower()
  if isinstance(m_title, unicode):
   m_title = m_title.encode('utf8')
  score = difflib.SequenceMatcher(None, m_title, l_title).ratio()
  if (_preferredLang and (_preferredLang == language)):
   score += 1
  scores.append((score, aka, language))
 scores.sort(reverse=True)
 if _titlesOnly:
  return [x[1] for x in scores]
 return scores

def sortAKAsBySimilarity ( movie , title , _titlesOnly = True , _preferredLang = None ) : language = movie . guessLanguage ( ) m_title = movie [ 'title' ] . lower ( ) l_title = title . lower ( ) if isinstance ( l_title , unicode ) : l_title = l_title . encode ( 'utf8' ) scores = [ ] score = difflib . SequenceMatcher ( None , m_title . encode ( 'utf8' ) , l_title ) . ratio ( ) scores . append ( ( score , movie [ 'title' ] , None ) ) for ( language , aka ) in akasLanguages ( movie ) : m_title = aka . lower ( ) if isinstance ( m_title , unicode ) : m_title = m_title . encode ( 'utf8' ) score = difflib . SequenceMatcher ( None , m_title , l_title ) . ratio ( ) if ( _preferredLang and ( _preferredLang == language ) ) : score += 1 scores . append ( ( score , aka , language ) ) scores . sort ( reverse = True ) if _titlesOnly : return [ x [ 1 ] for x in scores ] return scores
return a list of movie akas .