Create an algorithm to sort a given array of numbers.
Input: [7, 1, 3, 5, 9]
def sort_array(arr):
    arr.sort()
    return arr

print(sort_array([7, 1, 3, 5, 9]))
The algorithm should use a comparison function to compare two numbers and return a negative (if the first number is smaller than the second), zero (if the two numbers are equal), or a positive (if the first number is larger than the second) value. In this case, we could use the comparison function:

```
 int compare(int a, int b)
 {
   if (a < b) return -1;
   if (a > b) return 1;
   return 0;
 }
```

The algorithm should then sort the array using the following steps:

1. Initialize a variable to hold the index of the first element of the array.

2. Iterate through the length of the array, starting from the element at the index previously initialized.

3. Compare the element at the index with all preceding elements.

4. If the element is smaller than all preceding elements, keep it and make the element at the index equal to the smallest element seen so far.

5. If the element at the index is larger than all preceding elements, keep it and make the element at the index equal to the largest element seen so far.

6. When the loop ends, the array is sorted in ascending order.