Cmpsc 101, Project : Sorting

Write a program ( filename : sort_YourID.pl ) which :
  1. reads numbers from a data file ( filename : sorting.dat ). This file should contain a single number per line. The number of lines/numbers is arbitrary. Numbers can be negative, zero, or positive and the same number may occur multiple times.

  2. sort the numbers like mathematicians would in increasing order. For mathematicians -10 is less than -5 which itself is less than than 0. On the other hand 0 is less than +5 which in turn is less than +10.

  3. print to standard output ( the monitor ) the sorted numbers

In order to write this program you need knowledge of :

  1. if-elsif-else statements
  2. while-loop
  3. Reading from a file
  4. Using arrays


Zig Herzog; hgn@psu.edu
Send a Note to Zig
Last revised: 10/20/04