Sort a file 1.0

Operating systemsOS : Windows / Linux / Mac OS / BSD / Solaris
Program licensingScript Licensing : Other Free / Open Source License - Python License
CreatedCreated : Jun 6, 2007
Size downloadDownloads : 3
Program licensing
Thank you for voting...

This simple (4 lines) script will sort a file named ...

This simple (4 lines) script will Sort a file by Phil Robare named on the command line and write the sorted lines to standard output.
Sorting a nes to st common task for scripting languages. Using the fileinput module and the builtin capabilities of lists it can be done easily in Python.
An issue with the code as presented is that it doesn't check the filename that the user gives on the command line. If the name cannot be opened an IO error is thrown and you get an ugly traceback. It might also be more generally useful if the user were allowed to input a wildcard filename and the glob module were used to expand the wildcard to a list of files to be sorted.
This would bring up the question of whether the output should be a sort of the concatenation of the files or whether each file should be sorted seperately. The point of this recipe is to show a simple task done quickly so I have left these elaborations off.

Sort a file 1.0 scripting tags: file sorter, sort file, files, file tool, file management, task, sorted. What is new in Sort a file 1.0 software script? - Unable to find Sort a file 1.0 news. What is improvements are expecting? Newly-made Sort a file 1.1 will be downloaded from here. You may download directly. Please write the reviews of the Sort a file. License limitations are unspecified.