I have a list
, which contains several values, each group of values corresponds to an audio of a language, but I am not able to sort using two conditions.
audio_list = [{640: 640, 'lang': u'en', 'language': 'English', 'lang_code': 'en', 'bitrate': 640, 'size': 226600396}, {448: 448, 'lang': u'en', 'language': 'English', 'lang_code': 'en', 'bitrate': 448, 'size': 159037132}, {384: 384, 'lang': u'en', 'language': 'English', 'lang_code': 'en', 'bitrate': 384, 'size': 136516042}, {384: 384, 'lang': u'en', 'language': 'English', 'lang_code': 'en', 'bitrate': 384, 'size': 136516044}, {256: 256, 'lang': u'en', 'language': 'English', 'lang_code': 'en', 'bitrate': 256, 'size': 91473868}, {192: 192, 'lang': u'en', 'language': 'English', 'lang_code': 'en', 'bitrate': 192, 'size': 68952780}, {128: 128, 'lang': u'en', 'language': 'English', 'lang_code': 'en', 'bitrate': 128, 'size': 46431692}, {128: 128, 'lang': u'pt-BR', 'language': 'Brazilian', 'lang_code': 'pt-BR', 'bitrate': 128, 'size': 46431692}, {96: 96, 'lang': u'en', 'language': 'English', 'lang_code': 'en', 'bitrate': 96, 'size': 35171148}, {96: 96, 'lang': u'pt-BR', 'language': 'Brazilian', 'lang_code': 'pt-BR', 'bitrate': 96, 'size': 35171148}]
language = ['pt-BR', 'en']
for idx, language_code in enumerate(language):
max_audio = audio_list[ idx ]
lang_bitrate = max_audio.get('bitrate')
lang_name = max_audio.get('language')
print(lang_name + " - " + str(lang_bitrate))
When I run the above code, I get the following result:
English - 640
English - 448
But I should get the following result, sorted by the type of audio that comes first in language
and bitrate
:
Brazilian - 128
English - 640
How would I get the above result, sorted by% of audio% in% with%, and in order of% with%?