logo CodeStepByStep logo

reorder

Language/Type: Python list collections

Write a function named reorder that accepts as a parameter a list of integers that are already sorted by absolute value, and modifies it so that the integers are sorted normally. For example, if a list variable named nums stores the following elements:

[1, -2, 4, 5, -7, -9, -12, 28, -34]

Then the call of reorder(nums) should modify it to store the following values:

[-34, -12, -9, -7, -2, 1, 4, 5, 28]

Constraints: You may use a single list as auxiliary storage.

Function: Write a Python function as described, not a complete program.

You must log in before you can solve this problem.

Log In

Need help?

Stuck on an exercise? Contact your TA or instructor.

If something seems wrong with our site, please

Is there a problem? Contact us.