Link to home
Start Free TrialLog in
Avatar of csturner
csturner

asked on

sorting lines in pascal

my goal is to read from an input file and sort the lines(up to 500) alphbetically and then print the sorted list.  I am not using turbo pascal just pascal.  What is the best way to store and sort these lines of up to 80 characters?
ASKER CERTIFIED SOLUTION
Avatar of Nuno Alves
Nuno Alves

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of csturner
csturner

ASKER

I would still like to know HOW TO STORE THE LINES BY LINE IN ORDER TO SORT THEM BY LINE.  EX. NAMES IN THE TELEPHONE BOOK == GIVEN A LIST OF NAMES SORT THEM === How do I read them in and store them in order to do the sort.
Please be more specific.
I didn't understand what do you mean with "STORE THE LINES BY LINE IN ORDER TO SORT THEM BY LINE".
Do you want to know the specific algorithm to compare the lines to sort? that's it?
Ok.  This is my first pascal program so sorry if I sound cofusing: ) What I need to do is tale a text file and put lines in ascending order.  ex. The dog ran fast.
                         The cat meowed.
                         The man walked.

I f this is in my text file , I need to read it in sort it and print out:   The cat meowed.
             The dog ran fast.
             The man walked.

I am having trouble not in the area of sorting but in how to accomplish keeping up with the lines as I go.  I am not using Turbo Pascal which allows for strings or whatever.  I do not know how to store the lines in order to print them at a later time.
Something like an array of arrays or something?? I am not sure how to go about this.  If I can get the lines stored somewhere, I believe I can sort them ok.  I just can't get beyond that point.
Does pascal allow an easier way?  Like I said I am not to familar with the language.  Thank You for your help.
If you are using standart pascal you can use the following structure:

type
     string = packed array [1..80] of char;
var
     lines: array [1..500] of string;

I think that is what you want.
Regards