# Sorting in Python class 11 Notes with important Questions

Share with others

## What is Sorting in Python?

Sorting means to arrange elements in increasing or decreasing order. Sorting algorithm tells us that how we are going to arrange elements in increasing or decreasing order.

Output of sorting algorithm depends on the type of comparison operator used to arrange elements.

The sorting algorithm takes the elements(numbers or alphabets) and arrange them in particular order (increasing or decreasing)

for example : The sorting algorithms takes following numbers as input and arranged in increasing order

INPUT : 23, 12, 35, 40, 56, 20, 1

OUTPUT : 1, 12, 20, 23, 35, 40, 56

The sorting algorithms takes following numbers as input and arranged in decreasing order.

INPUT : 99, 88, 121, 10, 5, 112, 15, 1, 23

OUTPUT: 121, 112, 99, 88, 23, 15, 10, 5, 1

The sorting algorithms takes following alphabets as input and arranged in decreasing order of ASCII Value.

INPUT : A, b, C, E, d, F, D

OUTPUT : d, b, F, E, D, C, A

## Why Sorting is required?

Elements can be searched easily if data is arranged in increasing or decreasing order. Sorting arranged the data in more readable format.

## Sorting in daily life

We come across many things in our daily life which are arranged in increasing or decreasing order. for example

1. Words are arranged in alphabetical order in Dictionary
2. Pages in books are arranged in increasing order.
3. Phone numbers in telephone directory are arranged in alphabetical order.

## Types of Sorting algorithm

There are many sorting algorithm which can be used to arrange elements in increasing or decreasing order.

1. Bubble Sort
2. Insertion Sort
3. Quick Sort
4. Merge Sort
5. Selection Sort etc.

## Exercise :

Q1. What do you mean by Sorting in Python?

Q2. Name two Sorting algorithm.

Q3. Write the output of following list after applying bubble sort algorithm for arranging in increasing order.

L = [34, 56, 12, 3, 40, 78, 67]

Q4. Why Sorting is required?

Q5. Arrange the following list in increasing order.

L = [“A”, ‘b’, ‘D’, ‘g’ , ‘Z’ , ‘i’]

## Click for detail : Insertion Sort

Class 12 Computer Science Sample Paper 2020-2021.

Class 12 Computer Science Sample Paper Marking Scheme

Class 12 Computer Science Test Series

Share with others
error: Content is protected !!