Creating a sorted sporting ladder in a Pascal-created game

Posted on 2006-05-17
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.


Question by:grinsley
    LVL 10

    Expert Comment

    There are no built in pascal sorting functions. You have to create your own sorting code.
    LVL 100

    Accepted Solution

    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
                            For J := i to n - 1 do
                               If Points[j] > Points[j+1] then
                                     T := Points[j];
                                     Points[j] := Points[j+1];
                                     Points[j+1] := T

    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

    LVL 10

    Expert Comment

    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.
    LVL 14

    Expert Comment

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

    Author Comment

    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.
    LVL 100

    Expert Comment

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


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
    In the modern office, employees tend to move around the workplace a lot more freely. Conferences, collaborative groups, flexible seating and working from home require a new level of mobility. Technology has not only changed the behavior and the expe…
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    758 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

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now