def quicksort(unsorted_list, compare_func):
    """
    quicksort returns a sorted list from the elements of unsorted_list.
    compare_func is a function that takes in two arguments a and b(where
    a and b are of the same type in unsorted_list) and returns:
        True    if a should be sorted to the left of b
        False   if a should be sorted to the right of b

    The compare_func should be able to handle situations where a==b.

    :param unsorted_list: list
    :param compare_func: func
    :return: list
    """
    if len(unsorted_list) < 2:
        return unsorted_list

    m = unsorted_list[0]
    A, B = [], []
    for x in unsorted_list[1:]:
        if compare_func(x, m):
            A += [x]
        else:
            B += [x]

    return quicksort(A, compare_func) + [m] + quicksort(B, compare_func)