Write a complete program in MIPS assembly language that implements the selection sort algorithm to sort an array of integers in both ascending and descending order. The program must be based on the C code presented below.
# Performs a selection sort on the data with a comparator
void selection_sort(int* array, int len) {
for (int i = 0; i < len - 1; i++) {
int min_idx = i;
for (int j = i + 1; j < len; j++) {
// Do NOT inline compare! Your code will not work without calling compare
if (compare(array[j], array[min_idx])) {
min_idx = j;
}
}
if (min_idx != i) {
int tmp = array[i];
array[i] = array[min_idx];
array[min_idx] = tmp;
}
}
}