fdoc

subroutinesort_strings

subroutine sort_strings(list)

Sort list by byte value, removing duplicates.

Arguments

NameTypeIntentAttributesDescription
listtype(string_t)inoutallocatabledimension(:)

the list

Calls

Source

Show the code
subroutine sort_strings(list)
    type(string_t), allocatable, intent(inout) :: list(:)   !! the list
    type(string_t), allocatable :: out(:)
    character(len=:), allocatable :: t
    integer :: i, j

    do i = 2, size(list)
        call move_alloc(list(i)%s, t)
        j = i - 1
        do while (j >= 1)
            if (.not. llt(t, list(j)%s)) exit
            call move_alloc(list(j)%s, list(j + 1)%s)
            j = j - 1
        end do
        call move_alloc(t, list(j + 1)%s)
    end do
    allocate (out(0))
    do i = 1, size(list)
        if (i > 1) then
            if (list(i)%s == list(i - 1)%s) cycle
        end if
        call push(out, list(i)%s)
    end do
    call move_alloc(out, list)
end subroutine sort_strings

Graphs

Calls

Called by