from operator import add


def top_five_urls(rdd):
    """ 
        Return a rdd only with the top 5 url's
        with more requests by descending order.

        return type: pyspark.rdd.PipelinedRDD
    """

    urls_rdd = rdd.map(lambda line: line.split('"')[1].split(' ')[1])
    count_rdd = urls_rdd.map(lambda url: (url, 1)).reduceByKey(add)

    return count_rdd.sortBy(lambda el: -el[1]).take(5)