Sorting of the output by contribution and probabilities.