fdoc

subroutinesort_by_nameprivate

subroutine sort_by_name(list, ids)

Put ids, if there are any, in the order of their names.

Arguments

NameTypeIntentAttributesDescription
listtype(entity_list_t)in

the entities

idsintegerinoutallocatabledimension(:)

the entities to sort

Calls

Called by

Source

Show the code
subroutine sort_by_name(list, ids)
    type(entity_list_t), intent(in) :: list         !! the entities
    integer, allocatable, intent(inout) :: ids(:)   !! the entities to sort
    integer :: k, j, value

    if (.not. allocated(ids)) return
    do k = 2, size(ids)
        value = ids(k)
        j = k - 1
        do while (j >= 1)
            if (lowercase(list%box(ids(j))%e%name) <= lowercase(list%box(value)%e%name)) exit
            ids(j + 1) = ids(j)
            j = j - 1
        end do
        ids(j + 1) = value
    end do
end subroutine sort_by_name