title: How to find the minimum number of moves to sort a list?
body: <p>In a given list A of N distinct integer numbers, I would like to find the minimum number of moves required to sort the list by moving an element to the end of the list in ascending order.</p>
  
  <blockquote>
    <p>output is:1 4 3 2 5 [1, 3, 2, 5, 4] 1 [1, 2, 5, 4, 3] 2 [1, 2, 4, 3,
    5] 3 [1, 2, 3, 5, 4] 4 [1, 2, 3, 4, 5] 5 None</p>
  </blockquote>
  
  <pre><code>def end_sort(a,c):
      for i in range(len(a)):
          if(a[i]&gt;a[i+1]):
              a.append(a.pop(i))
              c+=1 
              print(a,c)
              break
      if(a!=sorted(a)):
          end_sort(a,c)
      else:
          return c 
  a=list(map(int,input().split(" ")))
  c=0
  co=end_sort(a,c)
  print(co,end="") 
  </code></pre>