

# https://www.globalsino.com/ICs/
# Sort a text file (with numbers only) in order 

import itertools

FileName = r"C:\0Python\csvForTests\TextTest2.txt"

file_object = open(FileName, 'r')
users = []
f1 = file_object.readlines()
print(f1)
# List after remove the "\n"
theListWithout_n = list(map(str.strip,f1))
print("theListWithout \\n:", theListWithout_n)

print("\n")
print("Sort theListWithout \\n:", sorted(theListWithout_n),": the sort did not sort correctly since this is a string list")
print("\n")
convertTheStringListToNumberList = []
for i in theListWithout_n:
    print(i)
    convertTheStringListToNumberList.append(int(i))
print(convertTheStringListToNumberList)

print("\nSort numbers in ascending Order: ", sorted(convertTheStringListToNumberList))

print("\nSort numbers in descending Order: ", sorted(convertTheStringListToNumberList, reverse=True))



