sort_segment_by_min Subroutine

public pure subroutine sort_segment_by_min(segments)

Arguments

Type IntentOptional Attributes Name
type(segment_t), intent(inout), allocatable :: segments(:)

Source Code

   pure subroutine sort_segment_by_min(segments)
      implicit none
      type(segment_t), allocatable, intent(inout) :: segments(:)

      integer :: i, j, n
      type(segment_t) :: temp ! temporary variable

      if (.not. allocated(segments)) return

      n = size(segments)
      do i = 1, n-1
         do j = i+1, n
            if (segments(i)%min > segments(j)%min) then
               temp = segments(i)
               segments(i) = segments(j)
               segments(j) = temp
            end if
         end do
      end do
   end subroutine sort_segment_by_min