I can handle large numbers with this code as well but I need to improve my execution time.def no_swap(a):  sorted_a=sorted(a)  rev_a=list(reversed(a))  b=a[:]  n=len(a)  noswap1=0  noswap2=0  for i in range(n):    if a[i]!=sorted_a[i]:      noswap1=noswap1+1      j=binarySearch(sorted_a[i],a)      a=swaplist(i,j,a)    if rev_a[i]!=sorted_a[i]:      noswap2=noswap2+1      j=binarySearch(sorted_a[i],rev_a)      b=swaplist(i,j,rev_a)  return min(noswap1,noswap2)def swaplist(i,j,arr):  temp=arr[i]  arr[i]=arr[j]  arr[j]=temp  return arrdef binarySearch(item, alist):  first = 0  last = len(alist)-1  found = False  while first<=last and not found:    midpoint = (first + last)    if alist[midpoint] == item:      found = True    else:      if item < alist[midpoint]:       last = midpoint-1      else:        first = midpoint+1  return midpointAny suggestions are appreciated!
Finding the minimum number of swaps to sort a list
python;algorithm;sorting