def bucketsort(arr, k):
    counts = [0] * k
    for x in arr:
        counts[x] += 1

    sorted_arr = []
    for i, count in enumerate(counts):
        sorted_arr.extend([i] * count)

    return sorted_arr

# Sample test
arr = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5]
k = 10
expected = [1, 1, 2, 3, 3, 4, 5, 5, 5, 6, 9]
assert(bucketsort(arr, k) == expected)