I am currently working with list format data and let's suppose I am having a list and I want to sort the elements from lowest to highest. How can I approach that?
The list: [-5, -23, 5, 0, 23, -6, 23, 67]
The desired list: [-23, -6, -5, 0, 5, 23, 23, 67]
This is the below code I have executed:
data_list = [-5, -23, 5, 0, 23, -6, 23, 67]
new_list = []
minimum = data_list[0] # arbitrary number in list
for x in data_list:
if x < minimum:
minimum = value
new_list.append(i)
However, the above goes through only once, and this is what I get:
new_list = [-23]
This is where I am getting stuck. Kindly help me!!