Question: #Create function called sort_artists. sort_artists will take as input a list of tuples. Each tuple will have two items: the first item will be a

#Create function called sort_artists. sort_artists will take as input a list of tuples. Each tuple will have two items: the first item will be a string holding an artist's name, and the second will be an integer representing their total album sales (in millions).
Return a tuple of two lists. The first list in the resulting tuple should be all the artists sorted alphabetically. The second list should be all the revenues sorted in descending numerical order.

For example:
artists = [("The Beatles", 270.8), ("Elvis Presley", 211.5), ("Michael Jackson", 183.9)]
 sort_artists(artists) -> (["Elvis Presley", "Michael Jackson", "The Beatles"], [270.8, 211.5, 183.9])

Notice that artists is a list of tuples (brackets first,then parentheses), but sort_artists outputs a tuple of
lists (parentheses first, then brackets).


Add function here!

 

Below are some lines of code that will test your function.You can change the value of the variable(s) to test your function with different inputs.
If your function works correctly, this will originally
print:
(['Elvis Presley', 'Michael Jackson', 'The Beatles'], [270.8, 211.5, 183.9])  
artists = [("The Beatles", 270.8), ("Elvis Presley", 211.5), ("Michael Jackson", 183.9)]
print(sort_artists(artists))

 

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Heres the sortartists function that sorts artists alphabetically and their revenues in d... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!