def rearrange_prediction(origin_classes, destination_classes, prediction):
    """Rearranges the probabilities in a compact array when the
       list of classes in the destination resource does not match the
       ones in the origin resource.

    """
    new_prediction = []
    for class_name in destination_classes:
        origin_index = origin_classes.index(class_name)
        if origin_index > -1:
            new_prediction.append(prediction[origin_index])
        else:
            new_prediction = 0.0
    return new_prediction
