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 14,739 views

## 2 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
• 2,980 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)```

as far as I am aware you can just do:

`list = [1, 3, 123, 1, 42, 123] # RANDOM NUMBERS`
`list.sort()` answered May 18 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)```

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

In Logic 1, try if i<int(length/2): instead of if i<int((length/2+1)): In ...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 to get permutations of list or a set in Python?

Permutation is an arrangement of objects in ...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

## how do i use the enumerate function inside a list?

can you give an example using a ...READ MORE