Create an algorithm that sorts a given array in ascending order.
Input: [4, 5, 2, 1, 3]
def sort_array(arr): 
    for i in range(len(arr)): 
        min_idx = i
        for j in range(i + 1, len(arr)): 
            if arr[min_idx] > arr[j]: 
                min_idx = j
        
        arr[i], arr[min_idx] = arr[min_idx], arr[i]
The algorithm can be done in two steps. First, the elements in the array must be ordered by their values. In this case, 1, 2, 3, 4, 5. Then, the elements must be ordered by their indices in the array (i.e., 1, 2, 3, 4, 5) which is ascending order.