Write a sorting algorithm for a numerical dataset in Python.

 

writing a sort algorithm- Python - i2tutorials

Sorting refers to arranging the given data in a particular format. A sorting algorithm specifies the way to arrange data in a particular format and order. It makes the data more readable and the data searching can be optimized to a very high level.

There are many kinds of sorting algorithms in python. These are:

  •  1. Bubble sort
  •  2. Merge sort
  •  3. Insertion sort
  •  4. Shell sort
  • 5.  Selection sort

A sorting algorithm for a given numerical dataset is given below:

This is a comparison based algorithm where each pair of adjacent elements is compared and the elements are swapped if they are not in order.