Returns true if the list is lexically sorted in increasing order.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(inout), | dimension(:) | :: | str | ||
logical, | intent(in) | :: | case_sensitive |
if true, the sort is case sensitive |
||
logical, | intent(in) | :: | natural |
if true, the sort is "natural" |
logical function list_is_sorted(str,case_sensitive,natural) result(sorted) implicit none character(len=*),dimension(:),intent(inout) :: str logical,intent(in) :: case_sensitive !! if true, the sort is case sensitive logical,intent(in) :: natural !! if true, the sort is "natural" type(int_list),dimension(size(str)) :: ints !! the `str` converted into arrays of integers logical,dimension(size(str)) :: case_sensitive_vec !! for the elemental routine integer :: i !! counter sorted = .true. if (natural) then !convert vector of strings to vector of int vectors: case_sensitive_vec = case_sensitive call string_to_int_list(str,case_sensitive_vec,ints) do i = 1, size(str)-1 if ( ints(i+1) < ints(i) ) then sorted = .false. return end if end do else do i = 1, size(str)-1 if (lexical_lt(str(i+1),str(i),case_sensitive)) then sorted = .false. return end if end do end if end function list_is_sorted