Solution: Python
def countSwaps(a):
n = len(a)
s = 0
for i in range(0, n):
for j in range(0, n-1):
if (a[j] > a[j + 1]):
s += 1
tmp = a[j]
a[j] = a[j+1]
a[j+1] = tmp
print("Array is sorted in",s,"swaps.")
print("First Element:",a[0])
print("Last Element:",a[n-1])