Creating a sorted sporting ladder in a Pascal-created game

I have created a simple game using Pascal 5.5. The program asks for 16 names of football (Aussie Rules) teams, and then pits these 16 teams against each other (using random numbers) in a 22-round season, ala the Australian Football League.

I am so far able to collate results from each 'round' into a ladder, but am unsure how to put the ladder in order from top team to bottom team. At the moment, the program just displays the teams in the order they are typed in at the start, with each team's wins, losses, ties, points for, points against, and percentage and points.

I want to be able to sort the ladder by points, then percentage.

I don't know much about any sort function in Pascal.

Thanks,
Grinsley

grinsleyAsked:
Who is Participating?
 
mlmccConnect With a Mentor Commented:
Can you show the data structures used?

Basic idea (slow sort but for you rpurposes will be fast enough)

                     For I := 1 to n - 1 do
                     Begin
                        For J := i to n - 1 do
                           If Points[j] > Points[j+1] then
                              Begin
                                 T := Points[j];
                                 Points[j] := Points[j+1];
                                 Points[j+1] := T
                              end
                     end


For your purpose you may have several swaps if you used parallel array.  If you used records for the teams and their information then the test will change

mlmcc
0
 
For-SoftCommented:
There are no built in pascal sorting functions. You have to create your own sorting code.
0
 
For-SoftCommented:
Oh. I forgot about the Turbo Vision library. There is a SortedCollection type there. Yet, it is necesary to create own compare methode. Because, Turbo Vision collections are able to sort string gata, only.

Anyways, using Turbo Vision requires some advanced programming techniques (pointer and object programming is a must).

And, I'm not sure if the Turbo Vision library was included in all Pascal 5.5 editions.
0
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

 
Pierre CorneliusCommented:
How are you storing the information? An array of record? Give details...
0
 
grinsleyAuthor Commented:
The thing is I've just been storing the information as separate integer variables. Is it possible to sort the data while it's all stored as separately named variables, or do I need to use an array? Each bit is stored as "teamapoints" "teambpoints" etc.
0
 
mlmccCommented:
It is possible but the code would be very poor.  You will need to use an array to facilitate checking and sorting.

mlmcc
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.