Im writing a MIPS assembly code that sorts a given array consisting of numbers.

Input: Array A of n items (numbers):
A[0] A[1] A[2] A[3] A[4] . . .
5 10 7 1 9 . . .

Output: Sorted Array A
A[0] A[1] A[2] A[3] A[4] . . .
1 5 7 9 10 . . .


------------------------------------------------------------

This is my MIPS code I have thusfar but I think its descending? instead of ascending.... im having issues hoping someone can give me some advice


My code:


-------------------------------------------------------------

.data
Array:
.word 14, 12, 13, 5, 9, 11, 3, 6, 7, 10, 2, 4, 8, 1

.text
.globl main
main:
la $s7, Array #load address Array in $s7
li $s0, 0 #load immediate i
li $s6, 9 #load immediate N-1
li $s1, 0 #load immediate j
sub_routine1:
sll $t7, $s1, 2
add $t7, $s7, $t7 # got the address of A[j]
lw $t0, 0($t7) #load word $t0 is A[j]
lw $t1, 4($t7) #load word $t1 is A[j+1]
sub $t2, $t0, $t1 #subtract $t0 to $t1 in $t2
bgtz $t2, no_swap #branch > 0
sw $t1, 0($t7) #$t0 is A[j]
sw $t0, 4($t7) #$t0 is A[j+1]
no_swap:

addi $s1, $s1, 1 #add immediate
sub $s5, $s6, $s0 #$s3 is N-i-1
bne $s1, $s5, sub_routine1 #branch not equal
addi $s0, $s0, 1 #add immediate
li $s1, 0 #load immediate j
bne $s0, $s6, sub_routine1 #branch not equal

done:
li $v0,4 #load immediate $v0
syscall
jr $ra #jump register