27174, "Guillaume-Helbecque", "[Documentation]: One code sample fails in 'Sort' doc", "2025-04-29T10:30:47Z"
Summary of Problem
In Sort
doc, the second code sample fails:
var Array = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5];
// Sort only the elements in the range 1..5
// Same as sort(Array[1..5]);
sort(Array, region=1..5);
// This will output: 3, 1, 1, 4, 5, 9, 2, 6, 5, 3, 5
writeln(Array);
with:
error: unresolved call 'sort([domain(1,int(64),one)] int(64), region=range(int(64),both,one))'
$CHPL_HOME/modules/standard/Sort.chpl:817: note: this candidate did not match: sort(ref x: [], comparator, region: range(?), param stable: bool = false)
note: because call does not supply enough arguments
$CHPL_HOME/modules/standard/Sort.chpl:817: note: it is missing a value for formal 'comparator'
note: other candidates are:
$CHPL_HOME/modules/standard/Sort.chpl:746: note: sort(ref x: [], comparator: ? = new defaultComparator(), param stable: bool = false)
$CHPL_HOME/modules/standard/Sort.chpl:777: note: sort(ref x: list(?), comparator: ? = new defaultComparator(), param stable: bool = false)
note: and 3 other candidates, use --print-all-candidates to see them
If I understand correclty, a fix could be to set a default comparator to sort(ref x: [], comparator, region: range(?), param stable: bool = false)
like for the other variants. Alternatively, the code sample could be changed to avoid using a region
argument, as there is "uncertainty about the usefulness of this routine".