def key_subtitles(subtitle, video, languages, services, order):
 key = ''
 for sort_item in order:
  if (sort_item == LANGUAGE_INDEX):
   key += '{0:03d}'.format(((len(languages) - languages.index(subtitle.language)) - 1))
   key += '{0:01d}'.format((subtitle.language == languages[languages.index(subtitle.language)]))
  elif (sort_item == SERVICE_INDEX):
   key += '{0:02d}'.format(((len(services) - services.index(subtitle.service)) - 1))
  elif (sort_item == SERVICE_CONFIDENCE):
   key += '{0:04d}'.format(int((subtitle.confidence * 1000)))
  elif (sort_item == MATCHING_CONFIDENCE):
   confidence = 0
   if subtitle.release:
    confidence = matching_confidence(video, subtitle)
   key += '{0:04d}'.format(int((confidence * 1000)))
 return int(key)

def key_subtitles ( subtitle , video , languages , services , order ) : key = '' for sort_item in order : if ( sort_item == LANGUAGE_INDEX ) : key += '{0:03d}' . format ( ( ( len ( languages ) - languages . index ( subtitle . language ) ) - 1 ) ) key += '{0:01d}' . format ( ( subtitle . language == languages [ languages . index ( subtitle . language ) ] ) ) elif ( sort_item == SERVICE_INDEX ) : key += '{0:02d}' . format ( ( ( len ( services ) - services . index ( subtitle . service ) ) - 1 ) ) elif ( sort_item == SERVICE_CONFIDENCE ) : key += '{0:04d}' . format ( int ( ( subtitle . confidence * 1000 ) ) ) elif ( sort_item == MATCHING_CONFIDENCE ) : confidence = 0 if subtitle . release : confidence = matching_confidence ( video , subtitle ) key += '{0:04d}' . format ( int ( ( confidence * 1000 ) ) ) return int ( key )
create a key to sort subtitle using the given order .