I needed to list specific documents for ditto to process, and I wanted them in the order I listed them in the &documents parameter. Unfortunately, Ditto 2.1.0 only processes these documents in the order they are given back from the database. So here’s how to change that default. Someone could probably take this and make it a selectable option.
In the ditto snippet code, change the following line
$resource = array_values($resource);
to
$resource = array_values($resource);
if($idType == "documents") {
$doc_ids = explode(",",$documents);
$new_resource = array();
$doc_order=array();
// map document id => sort order
for($x=0;$x<count($doc_ids);$x++) {
$doc_order[$doc_ids[$x]] = $x;
}
// put resource items into array in proper order
for($x=0;$x<count($resource);$x++) {
// put each document into the array in the right spot (determined by the $doc_order array)
$new_resource[ $doc_order[ $resource[$x]["id"] ] ] = $resource[$x];
}
// return the array in the correct order
$resource = $new_resource;
}
I hope someone finds this helpful.