def METHOD_NAME(pivots, data, compare, prefix=None):
    remove_file_buckets(prefix)
    buckets = _create_empty_bucket_list()
    buckets_size = 0
    if is_rank_zero():
        print("Writing "  + str(len(buckets)) + " file bucket(s)")
    count = 1
    for element in data:
        _put_element_in_bucket(element, pivots, buckets, compare)
        buckets_size += 1
        if buckets_size > 1000000:
            _empty_buckets(buckets, prefix)
            buckets_size = 0
        if is_rank_zero() and count % 100000 == 0:
            print("Bucketed " + str(count) + " cell(s) of " + str(len(data)))
        count += 1
    _empty_buckets(buckets, prefix)
    barrier()