This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
> #Selection Sort Doubt: why isn't a being updated. > a = [5,4,3,2,1] > n = 5 > for i in range(n-1): > min = a[i] > for j in range(i+1,n): > if min > a[j]: > min = a[j] > if j == n-1: > a[i],a[a.index(min)] = a[a.index(min)],a[i] > > print(a) > > This code still outputs [5, 4, 3, 2, 1]. Can you tell me why the list a isn't being updated? > I came across this question elsewhere and I'm really grateful that Clojure just makes this class of problems disappear! 😄