Personally i'd store the data in arrays, ie have an array of integers for the points, goals and team names.
you could have a couple of nested loops and test for the biggest value of points, then the second biggest etc
e.g.
Code:
array of integers biggest[4] = 0 (i.e. an array of 4 integers all set to 0)
array of integers dummy[4] (an array of integers to copy the points data)
for n = 0 to 4
{
dummy[n] = points[n] // copy all to a dummy array that you can delete stuff from
}
for i = 0 to 3 //i basically is the ranking i.e. i=0 is the top team in the group and i = 3 the bottom
{
for j = 0 to 3
{
if dummy[j] > biggest[i] OR dummy[j] = biggest[i] AND goals bigger
{
biggest[i] = j //stores which team had the highest points
}
}
dummy[biggest[i]] = 0; // remove whichever team had the highest points from consideration next time
}
at the end biggest[0] should indicate the best team and biggest[3] the worst
Alternatively you can use a bubble sort algorithm.
pseudo code:
for i = 3 downto 0
{
for j = 0 to i-1
{
if points[j] > points[j+1] OR if (points are equal AND goals [j] > goals [j+1])
{
//if team j has more points than team j+1
//then swap them over using dummy variables to hold j's data temporarily
dummy_points = points[j]
dummy_name = name[j]
dummy_goals = goals[j]
points[j] = points[j+1]
points[j+1] = dummy_points
name[j] = name[j+1]
name[j+1] = dummy_name
goals[j] = goals[j+1]
goals[j+1] = dummy_goals
}
}
}
Then jsut print the arrays out from 0 to 3
http://en.wikipedia.org/wiki/Bubble_sort
Clear as mud?