def histogram(values, mode=0, bin_function=None):
    """Return a list of (value, count) pairs, summarizing the input values.
    Sorted by increasing value, or if mode=1, by decreasing count.
    If bin_function is given, map it over values first."""
    if bin_function: values = map(bin_function, values)
    bins = {}
    for val in values:
        bins[val] = bins.get(val, 0) + 1
    if mode:
        return sorted(bins.items(), key=lambda x: (x[1],x[0]), reverse=True)
    else:
        return sorted(bins.items())
def histogram(values, mode=0, bin_function=None):
    """Return a list of (value, count) pairs, summarizing the input values.
    Sorted by increasing value, or if mode=1, by decreasing count.
    If bin_function is given, map it over values first."""
    if bin_function: values = map(bin_function, values)
    bins = {}
    for val in values:
        bins[val] = bins.get(val, 0) + 1
    if mode:
        return sorted(bins.items(), key=lambda x: (x[1],x[0]), reverse=True)
    else:
        return sorted(bins.items())
def histogram ( values , mode = 0 , bin_function = None ) : if bin_function : values = map ( bin_function , values ) bins = { } for val in values : bins [ val ] = bins . get ( val , 0 ) + 1 if mode : return sorted ( bins . items ( ) , key = lambda x : ( x [ 1 ] , x [ 0 ] ) , reverse = True ) else : return sorted ( bins . items ( ) )
Return a list of (value, count) pairs, summarizing the input values.
    Sorted by increasing value, or if mode=1, by decreasing count.
    If bin_function is given, map it over values first.
Return a list of ( value count ) pairs summarizing the input values . Sorted by increasing value or if mode = 1 by decreasing count . If bin_function is given map it over values first .