Question: Question 2 Read up about the odd-even sort algorithm on Wikipedia (https://en.wikipedia.org/wiki/Odd%E2%80%93even_sort). Write a function odd_even_sort that takes a list or numpy array and sorts

 Question 2 Read up about the odd-even sort algorithm on Wikipedia

Question 2 Read up about the odd-even sort algorithm on Wikipedia (https://en.wikipedia.org/wiki/Odd%E2%80%93even_sort). Write a function odd_even_sort that takes a list or numpy array and sorts it in ascending order using the odd-even sort algorithm. The function should return the modified list. You should assume that all entries in the list or array are single real numbers or integers. Test that, run on the input list [1, 7, -2, 5], your function returns the list [-2, 1, 5, 7]. Question 3 Write a function weird_sort that, given a list or numpy array of integers, sorts them in ascending order of the value of |a-5%, where a is the value of the item. The function should return the modified list. Test that, run on the input list [-2, 2, 0, 6], your function returns the list [6, 2,0, -2] (since |-2-5| = 7, 12-5| = 3, 10-5 5, and 16-5 1)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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 Databases Questions!