sort_build_runs_permutation Interface

interface
public module subroutine sort_build_runs_permutation(keys, n, group_keys, perm, tie)

Arguments

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

the keys, in precedence order.

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

rows.

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

leading keys that decide a tie.

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

receives n 1-based row indices.

integer(kind=c_int8_t), intent(inout) :: tie(:)

1 where a row ties with its predecessor.

Description

Sorts, then flags where the runs of EQUAL rows begin. tie(1) is always 0.

group_keys is how many LEADING keys decide a tie; the sort itself always uses every key. That asymmetry is what produces "grouped by field, ordered within group".