diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..dba7750 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,15 @@ +# Contributing + +When contributing to this repository, please first discuss the change you wish to make via issue, +email, or any other method with the owners of this repository before making a change. + +Please note we have a code of conduct, please follow it in all your interactions with the project. + +## Any contributions you make will be under the MIT Software License +In short, when you submit code changes, your submissions are understood to be under the same [MIT License](http://choosealicense.com/licenses/mit/) that covers the project. Feel free to contact the maintainers if that's a concern. + +## Report bugs using Github's [issues](https://github.com/Sagar-Sharma-7/Python-list-sorting-algorithms/issues) +We use GitHub issues to track public bugs. Report a bug by opening a new issue; it's that easy! + +## Owner Of the Repository - Sagar Sharma +[Sagar Sharma](https://github.com/Sagar-Sharma-7) diff --git a/README.md b/README.md new file mode 100644 index 0000000..88dcd8d --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +# Python-list-sorting-algorithms +Contains easy and short python list sorting algorithms ( Only for numbers as per now) diff --git a/algorithms/app2.py b/algorithms/app2.py new file mode 100644 index 0000000..e003af9 --- /dev/null +++ b/algorithms/app2.py @@ -0,0 +1,15 @@ +# Selection sorting +l = eval(input("Enter your number list: ")) +n = len(l) +for i in range(0, n): + min = i + f = False + for j in range(i + 1, n): + if l[j] < l[min]: + min = j + f = True + if f == True: + l[i], l[min] = l[min], l[i] + print(l) + +print("Sorted list: ", l) \ No newline at end of file diff --git a/algorithms/app3.py b/algorithms/app3.py new file mode 100644 index 0000000..c0eefee --- /dev/null +++ b/algorithms/app3.py @@ -0,0 +1,13 @@ +# Insertion sorting +l = eval(input("Enter your number list: ")) +n = len(l) +for i in range(n): + t = l[i] + k = i - 1 + while k >=0 and l[k] > t: + l[k + 1] = l[k] + k = k- 1 + l[k + 1] = t + print(l) + +print("Sorted list: ", l)