Sort an integer array in ascending order.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer, | intent(inout), | allocatable | :: | values(:) |
Integer array sorted in ascending order in-place |
subroutine sort_int_array(values) !! Sort an integer array in ascending order. implicit none ! Arguments integer, allocatable, intent(inout) :: values(:) !! Integer array sorted in ascending order in-place ! Local variables integer :: i, j, tmp !! Loop indices and swap temporary if(size(values) .le. 1) return do i = 1, size(values) - 1 do j = i + 1, size(values) if(values(j) .lt. values(i))then tmp = values(i) values(i) = values(j) values(j) = tmp end if end do end do end subroutine sort_int_array