Final Challenge #2
Lesson 9 of 9 in Coddy's Selection Sort - DSA Series course.
Challenge
MediumOne more challenge to master the pattern.
Sort the array by absolute value in ascending order, and return it. The absolute value of a number is its distance from zero, so -5 and 5 both have an absolute value of 5.
When two numbers have the same absolute value, the smaller (more negative) number should come first. For example, [-3, 3, 1] becomes [1, -3, 3].
Try it yourself
#include <stdlib.h>
int* selectionSort(int* arr, int arr_size, int* returnSize) {
// Write code here
*returnSize = arr_size;
return arr;
}