python - My quicksort code is not working. What's wrong with it? -


def quicksort(a):   if len(a) > 1:      pivot = a[0]      = 1      j = len(a)-1      while j >= i:         if a[i] < a[0]:            += 1         elif a[j] > a[0]:            j = j-1         elif a[i] > a[0] , a[j] < a[0]:            a[i],a[j] = a[j],a[i]            += 1            j = j-1      a[0],a[j] = a[j],a[0]      quicksort(a[:j])      quicksort(a[j+1:])  = [9,4,1,3,2,5,8,6,7]  quicksort(a)  print 

in result,all getting list returned first , last values swapped.


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -