From c21dac96778402e9acea11431cce5efc167605f6 Mon Sep 17 00:00:00 2001 From: ankay212000 Date: Fri, 28 Jun 2019 13:31:48 +0530 Subject: [PATCH] resolve issue#111 --- programs/Python/sorting.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 programs/Python/sorting.py diff --git a/programs/Python/sorting.py b/programs/Python/sorting.py new file mode 100644 index 0000000..e06e4ee --- /dev/null +++ b/programs/Python/sorting.py @@ -0,0 +1,18 @@ +arr=[] +num=int(input("enter no. of elements: ")) #no. of elements in the array +for i in range(num): + element=int(input("element"+str(i+1)+": ")) + arr.append(element) +print("Original array: ") +print(arr) +#sort function +def sorting(arr): + for i in range(n): + for j in range(i+1,n): + if (arr[i]>arr[j]): + temp=arr[i] + arr[i]=arr[j] + arr[j]=temp + return arr +print("sorted array: ") +print(sorted(arr))