sort_partial_permutation Interface

interface
public module subroutine sort_partial_permutation(keys, n, count, perm)

Arguments

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

the keys, in precedence order.

integer(kind=int64), intent(in) :: n

rows available.

integer(kind=int64), intent(in) :: count

leading entries to order.

integer(kind=int64), intent(inout) :: perm(:)

receives count 1-based row indices.

Description

The first count entries of the sorted permutation, by heap selection.

std::partial_sort's algorithm, not a full sort truncated -- a test counts comparisons to hold that apart. Everything past count in perm is untouched.