#!/usr/bin/python


def outlierCleaner(predictions, ages, net_worths):
    """
        Clean away the 10% of points that have the largest
        residual errors (difference between the prediction
        and the actual net worth).

        Return a list of tuples named cleaned_data where 
        each tuple is of the form (age, net_worth, error).
    """
#    from numpy import dot
    err = predictions - net_worths
    data = zip(ages, net_worths, err)
    cleaned_data = sorted(data, key = lambda x: x[2])[:int(.9*len(data))]

    ### your code goes here

    
    return cleaned_data

