how to sort a list of numbers without using built-in functions like min, max or any other function?

0 votes
Is it possible to sort a list of numbers without using built-in functions? If yes how to do it?
Jun 27 in Python by Arvind
• 2,600 points
35 views

1 answer to this question.

0 votes

Yes it is possible. You can refer to the following code to understand it.

my_list = [-15, -26, 15, 1, 23, -64, 23, 76]
new_list = []

while my_list:
    min = my_list[0]  
    for x in my_list: 
        if x < min:
            min = x
    new_list.append(min)
    my_list.remove(min)    

print(new_list)
answered Jun 27 by Arvind
• 2,600 points

Related Questions In Python

0 votes
1 answer
0 votes
1 answer

Is there a way to list out in-built variables and functions of Python?

The in-built variables and functions are defined ...READ MORE

answered May 14 in Python by Junaid
30 views
0 votes
1 answer

How can I write a program to add two numbers using functions in python?

def add(a,b):      return a + b #when i call ...READ MORE

answered May 20 in Python by Mohammad
• 3,060 points
45 views
0 votes
1 answer

How to get permutations of list or a set in Python?

Permutation is an arrangement of objects in ...READ MORE

answered Jul 11 in Python by Neel
• 2,450 points
30 views
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 6 in Python by Neha
• 330 points

edited Jul 8 by Kalgi 169 views
0 votes
1 answer

How to get a list of built in modules in Python?

simply open the python shell and type ...READ MORE

answered Aug 1 in Python by Arvind
• 2,600 points
25 views
0 votes
1 answer

How to check whether something is a variable or a function in Python?

Suppose you have a variable defined in ...READ MORE

answered Jul 30 in Python by Arvind
• 2,600 points
14 views