?
Solved

Creating a sorted sporting ladder in a Pascal-created game

Posted on 2006-05-17
7
Medium Priority
?
345 Views
Last Modified: 2010-04-16
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

0
Comment
Question by:grinsley
6 Comments
 
LVL 10

Expert Comment

by:For-Soft
ID: 16712056
There are no built in pascal sorting functions. You have to create your own sorting code.
0
 
LVL 101

Accepted Solution

by:
mlmcc earned 375 total points
ID: 16714777
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
 
LVL 10

Expert Comment

by:For-Soft
ID: 16715353
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
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 14

Expert Comment

by:Pierre Cornelius
ID: 16758913
How are you storing the information? An array of record? Give details...
0
 

Author Comment

by:grinsley
ID: 16765510
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
 
LVL 101

Expert Comment

by:mlmcc
ID: 16765533
It is possible but the code would be very poor.  You will need to use an array to facilitate checking and sorting.

mlmcc
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I came across an unsolved Outlook issue and here is my solution.
MSSQL DB-maintenance also needs implementation of multiple activities. However, unprecedented errors can hamper the database management. In that case, deploying Stellar SQL Database Toolkit ensures fast and accurate database and backup repair as wel…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question