sort_build_permutation Interface

interface
public module subroutine sort_build_permutation(keys, n, 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 to order.

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

receives n 1-based row indices.

Description

THE engine entry point: the counting fast path where it applies, the introsort otherwise.

Mirrors the C++ sort_build_permutation exactly, including that the range scan's lo/hi are carried from the candidate test into the placement pass rather than rescanned. The two paths answer identically — the counting one is stable by construction, which is the same answer the comparator's index tiebreaker gives.