input: Write a python function to calculate the minimum number of swaps required to sort an array.
  assert min_swaps([4, 3, 1, 2]) == 3
  assert min_swaps([1, 5, 4, 3, 2]) == 4
  assert min_swaps([7, 1, 3, 2, 4, 5, 6]) == 5
output: def min_swaps(arr):
      n = len(arr)
      arrpos = [*enumerate(arr)]
      arrpos.sort(key=lambda it: it[1])
      vis = {k: False for k in range(n)}
      ans = 0
  
      for i in range(n):
          if vis[i] or arrpos[i][0] == i:
              continue
  
          cycle_size = 0
          j = i
          while not vis[j]:
              vis[j] = True
              j = arrpos[j][0]
              cycle_size += 1
  
          if cycle_size > 0:
              ans += (cycle_size - 1)
      return ans