sorted_order Function

public function sorted_order(keys) result(order)

The order in which keys are sorted (a stable sort, comparing in ASCII order).

Arguments

Type IntentOptional Attributes Name
type(string_t), intent(in) :: keys(:)

the sort keys

Return Value integer, allocatable, (:)


Called by

proc~~sorted_order~~CalledByGraph proc~sorted_order sorted_order proc~code_signature code_signature proc~code_signature->proc~sorted_order proc~sort_only_list sort_only_list proc~sort_only_list->proc~sorted_order proc~sort_use sort_use proc~sort_use->proc~sorted_order proc~sort_use->proc~sort_only_list proc~format_text format_text proc~format_text->proc~sort_use proc~same_code same_code proc~same_code->proc~code_signature proc~process_text process_text proc~process_text->proc~format_text proc~process_file process_file proc~process_file->proc~process_text proc~process_stdin process_stdin proc~process_stdin->proc~process_text proc~run run proc~run->proc~process_file proc~run->proc~process_stdin

Source Code

function sorted_order(keys) result(order)
    !! The order in which `keys` are sorted (a stable sort, comparing in ASCII order).
    type(string_t), intent(in) :: keys(:)   !! the sort keys
    integer, allocatable :: order(:)
    integer :: i, j, t

    order = [(i, i=1, size(keys))]
    do i = 2, size(keys)
        t = order(i)
        j = i - 1
        do while (j >= 1)
            if (.not. llt(keys(t)%s, keys(order(j))%s)) exit
            order(j + 1) = order(j)
            j = j - 1
        end do
        order(j + 1) = t
    end do
end function sorted_order