# File: ChapterLists/sort.py
"""
Enter number (q for quit )? > 4
Enter number (q for quit )? > 3
Enter number (q for quit )? > 5
Enter number (q for quit )? > q
[4, 3, 5] is sorted? False
[3, 4, 5] is sorted? True
"""
def checkSort(L): #check ascending sort
for i in range(len(L)-1):
if ( not (L[i] <= L[i+1] )):
return False
return True
def main():
x = 1
L = [] # initialize list
x = input("Enter number (q for quit )? > ")
while (x != 'q' and x != 'Q'): # stop when type q or Q
L.append( int(x) )
x = input("Enter number (q for quit )? > ")
print(L, " is sorted? ",checkSort(L))
L.sort()
print(L, " is sorted? ", checkSort(L))
main()