Question
*****Don't USE bubble sort tehnique should Sorts based on ASCII value or dictionary key value !!!!!!!!!!!!!!!!!!!!!!!!! Use python language write code with explanation , should
*****Don't USE bubble sort tehnique
should Sorts based on ASCII value or dictionary key value !!!!!!!!!!!!!!!!!!!!!!!!!
Use python language write code with explanation ,
should show screenshot (code, input ,output ),Please .
Write a function, sort_by_key() that takes as input top_100 table and an integer, i, and
returns a copy of the table in sorted order based on a given index. E.g, sort_by_key(top_100, 0)
would sort the table based on the song name column (ensuring the song name still matches
up with its accompanying information). sort the data presented as a string, it sorts based on ASCII value. Ensure that you do not alter the original list and that a
stable sorting algorithm is used.
Function header: sort_by_key(top_100,key)
Input: top_100: the top_100 table as attached photo.
key: An integer value corresponding to an index of the top_100 table, by which the list is to be
sorted.
Output: A copy of the input table sorted by values in column key.
Write a short analysis on the complexity of your sorting algorithm (~400 words).
Detail the best and worst case complexities and the input(s) that will cause them.
Detail what techniques you employed to maintain stability.
Examples:
>>> top_100 = filter_table(top_100)
>>> sorted_table = sort_table(top_100, 0))
>>> print(sorted_table)
[['10,000 Hours', 'Dan + Shay & Justin Bieber', 4, 30, 17.47, '05:07'],
['Adore You', 'Harry Styles', 6, 21, 5.34, '01:09'], ['After A Few', 'Travis
Denning', 44, 5, 3.63, '03:05'],...]
>>> sorted_table = sort_table(top_100, 1)
>>> print(sorted_table)
[['Underdog', 'Alicia Keys', 69, 5, 1.36, '04:01'], ['Roxanne', 'Arizona
Zervas', 4, 26, 12.73, '05:55'], ['Supalonely', 'BENEE Featuring Gus
Dapperton', 48, 7, 6.93, '03:14'],...]
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started