python

hoart_sort() takes 1 positional argument but 5 were given

from random import choice
def hoar_sort(A):
 from random import choice
def hoar_sort(A):
if len(A)<=1:
return A
barier=random.choice(A)
left=[x for x in A if x<barier]
middle=[x for x in A if x==barier]
rigt=[x for x in A if x>barier]
left=hoar_sort(left)
right=hoar_sort(right)
return left+middle+right

there is a problem?

You need to show us your initial invocation of hoar_sort.

You might also try changing:

left=hoar_sort(left)
right=hoar_sort(right)
return left+middle+right

to this:

left2=hoar_sort(left)
right2=hoar_sort(right)
return left2+middle+right2

By using the same name for your input and output you might be confusing the list instances.

2 Likes