Is it possible to sort a list of numbers without using built-in functions? If yes how to do it? Jun 27, 2019 in Python 99,342 views

## 4 answers to this question.

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
for x in my_list:
if x < min:
min = x
new_list.append(min)
my_list.remove(min)

print(new_list)``` answered Jun 27, 2019 by
• 3,040 points
Min function is there
Sort a given List in ascending order without using any inbuilt Sorting Methods and Functions.?

Hey,

You can try this:

```NumList = []

Number = int(input("Please enter the Total Number of List Elements: "))
for i in range(1, Number + 1):
value = int(input("Please enter the Value of %d Element : " %i))
NumList.append(value)

for i in range (Number):
for j in range(i + 1, Number):
if(NumList[i] > NumList[j]):
temp = NumList[i]
NumList[i] = NumList[j]
NumList[j] = temp

print("Element After Sorting List in Ascending Order is : ", NumList)```

–1 vote

as far as I am aware you can just do:

`list = [1, 3, 123, 1, 42, 123] # RANDOM NUMBERS`
`list.sort()` answered May 19, 2020 by anonymous
list.sort is a built in function
 Hii, Yes,sort() is a built in function in python. The sort() method sorts the list ascending by default. You can also make a function to decide the sorting criteria(s). Syntax `list.sort(reverse=True|False, key=myFunc)` where, reverse-Optional. reverse=True will sort the list descending. Default is reverse=False key-Optional. A function to specify the sorting criteria(s) Hope it is helpful!! Thanks!!
`Questions:how to sort a list of numbers without using built-in functions from command prompt.please try this code.`
`import sys`
```sortval=[]
val=sys.argv[1:]```
```print("val:",val)
for i in val:
val=int(i)
sortval.append(val)
print("before sortval:",sortval)
for i in range(len(sortval)):
for j in range(i+1,len(sortval)):
if(sortval[i]>sortval[j]):
temp=sortval[i]
sortval[i]=sortval[j]
sortval[j]=temp
print("Aftersortval:",sortval)```

Python Program to Sort List in Ascending Order without using Sort. In this program, we are using Nested For Loop to iterate each number in a list, and sort them in ascending order.

if(NumList > NumList) = if(67 > 86) –

It means the condition is False.

So, it exits from the If block, and the j value incremented by 1. answered Dec 12, 2020 by
• 65,870 points
+1 vote

I guess you are trying to do something like this:

```data_list = [-5, -23, 5, 0, 23, -6, 23, 67]
new_list = []

while data_list:
minimum = data_list  # arbitrary number in list
for x in data_list:
if x < minimum:
minimum = x
new_list.append(minimum)
data_list.remove(minimum)

print new_list``` answered Dec 12, 2020 by
• 8,910 points

## ) Write a program that sorts a given list, once in ascending and then in descending order, without using the sort() built-in function

Hi, @There, Given an array of size n, ...READ MORE

## How can I write code to find a palindrome in python without using string functions?

x="malayalam" y="" for i in x: ...READ MORE

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

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

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

there is sum() function as a built ...READ MORE

## how do i change string to a list?

suppose you have a string with a ...READ MORE

## how can i randomly select items from a list?

You can also use the random library's ...READ MORE

+1 vote

## how can i count the items in a list?

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