## Here is the first way to sort:

``````

In :

# Pseudocode:
# Creat a empty sort_list,
# Assume the first number of the input list is the minimum,
# Compare the number with the "minimum",
# If number less than the minimum, it becomes the new minimum
# Append the "new minimum" in the sort_list and remove it from input_list at the same time
# Repeat it till there is none in the original list.
# Which means all the numbers have been added into sort_list one by one as "new minimum".
# The while loop stops, return the new sorted list.

def to_sort(input_list):
sort_list = []
while input_list:
minimum = input_list
for number in input_list:
if number < minimum:
minimum = number
sort_list.append(minimum)
input_list.remove(minimum)
return sort_list

``````
``````

In :

# Test 10
a = [5,222,4,31,3123,-109,22,15,-10,0]
%time to_sort(a)

``````
``````

CPU times: user 16 µs, sys: 0 ns, total: 16 µs
Wall time: 18.8 µs

Out:

[-109, -10, 0, 4, 5, 15, 22, 31, 222, 3123]

``````
``````

In :

import random

``````
``````

In :

# Test 100
test_100 = random.sample(range(1,10000), 100)
#%time to_sort(test_100)
#CPU times: user 477 µs, sys: 0 ns, total: 477 µs
#Wall time: 482 µs

``````
``````

In :

# Test 1000
test_1000 = random.sample(range(1,100000), 1000)
#%time to_sort(test_1000)
#CPU times: user 38.2 ms, sys: 1.06 ms, total: 39.3 ms
#Wall time: 39 ms

``````

## Here is the second way to sort:

``````

In :

# Pseudocode:
# Old_list is the unsorted list
# For index in the range(len(old_list))
# Start from the first number, compare it with the next one.
# If the left one is greater than the right one，exchange them.
# Else, nothing changes, go back and continue
# Repeat it till the minimum becomes the first number.

def waytwo(old_list):
for i in range(len(old_list)):
for j in range(len(old_list)-1):
if old_list[j] > old_list[j+1]:
old_list[j+1], old_list[j] = old_list[j], old_list[j+1]
return old_list

``````
``````

In :

# Test 10
a = [5,222,4,31,3123,-109,22,15,-10,0]
%time waytwo(a)

``````
``````

CPU times: user 32 µs, sys: 0 ns, total: 32 µs
Wall time: 34.8 µs

Out:

[-109, -10, 0, 4, 5, 15, 22, 31, 222, 3123]

``````
``````

In :

# Test 100
test2_100 = random.sample(range(1,10000), 100)
#%time to_sort(test2_100)
#CPU times: user 391 µs, sys: 0 ns, total: 391 µs
#Wall time: 395 µs

``````
``````

In :

# Test 1000
test2_1000 = random.sample(range(1,100000), 1000)
#%time to_sort(test2_1000)
#CPU times: user 43.1 ms, sys: 832 µs, total: 43.9 ms
#Wall time: 43.5 ms

``````
``````

In [ ]:

``````