Preserve order in distinctBy

WorkflowBuilder now inspects the merged source workflow and if it is ordered,
attempts to reconstruct the $sort op after grouping. This works only if the
source pipeline has one of a couple of recognized shapes.