Try this, the function will do the work. I changed the test values of your artists
list to show that it works.
def sort_artists(x):
artist = []
earnings = []
for inner in x:
artist.append(inner[0])
earnings.append(inner[1])
index = sorted(range(len(earnings)), key=lambda k: earnings[k])
artist = [artist[i] for i in index]
earnings = [earnings[i] for i in index]
z = (artist, earnings)
return z
artists = [("The Beatles", 250), ("Elvis Presley", 530), ("Michael Jackson", 120)]
print(sort_artists(artists))
Output:
(['Michael Jackson', 'The Beatles', 'Elvis Presley'], [120, 250, 530])
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…