# Sort.py Copyright (c) Kari Laitinen # http://www.naturalprogramming.com # 2006-05-23 File created. # 2022-12-16 Converted to Python 3. # This is the main program of an example program in which # the given numbers are sorted. # The program files SortMain.py, InputOutput.py, and Sort.py # correspond to single program files (e.g. Sort.java) written # with other programming languages. # This program shows how Python functions defined in other # .py files can be used. In Python terminology another .py # file is another Python module. Modules must be imported # with import statements before the functions defined inside # the modules can be used. # When this program is executed, files InputOutput.py and Sort.py # must be in the same folder (directory) where this file is located. import InputOutput import Sort list_of_numbers = [] print( "\n This program sorts the numbers that you enter" \ "\n from the keyboard. The program stops asking for new" \ "\n numbers when you enter a letter. \n" ) number_of_numbers_read = InputOutput.ask_numbers_to_list( list_of_numbers ) Sort.sort_to_ascending_order( list_of_numbers, number_of_numbers_read ) InputOutput.print_list_of_numbers( list_of_numbers, number_of_numbers_read ) # Note that there is the standard sort() method that can sort a # Python list. The list used in this program could be sorted # with the statement # list_of_numbers.sort() # sort to ascending order # This statement would sort the entire list, whereas # Sort.sort_to_ascending_order() can be used to sort a part of # a list.