sort_counting_permutation Interface

interface
public module subroutine sort_counting_permutation(key, n, lo, hi, perm)

Arguments

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

the lone integer key.

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

rows.

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

smallest valid key value.

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

largest valid key value.

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

receives n 1-based row indices.

Description

Fills perm by counting sort over lo..hi, with the nulls placed as one block.

Two O(n) passes and no comparisons at all. Stable by construction: the placement pass walks the input in index order, so equal values are emitted in file order — the same answer sort_row_less's index tiebreaker produces.