/ Forside / Teknologi / Udvikling / ASP / Nyhedsindlæg
Login
Glemt dit kodeord?
Brugernavn

Kodeord


Reklame
Top 10 brugere
ASP
#NavnPoint
smorch 9259
Harlekin 1866
molokyle 1040
Steffanst.. 758
gandalf 657
smilly 564
gibson 560
cumano 530
MouseKeep.. 480
10  Random 410
Sorting algorithm help?
Fra : Quinn


Dato : 12-02-03 00:23

Hi!

I am trying to generate a league table from a sports league automatically by
using ASP and a Database.
I want to register the results in a database table which looks like this:

TABLE NAME: League
id*
season
round
hometeam_id
awayteam_id
hometeam_score
awayteam_score

I then use SUM and COUNT functions to add the team's scores up. This is
going pretty well.
Then comes my problem - how do i sort the league table so that the team with
the most points comes first?
It should be sorted first on points, then on (goals_scored - goals_conceded)
and finally on goals scored.

Until now I have put each team in an array like this
teamA = "teamName, played, won, drawn, lost, goals_scored, goals_conceded,
points"

How do I go about sorting this? I have heard about an algorithm called
bubble sort, but I looked at it and couldn't quite figure it out.
Also I have the problem that if a team has played, say only 1 game, and
scored 0 goals, the output from the SUM() of goals isn't 0 but "".
How can I fix this?

I would REALLY appreciate if someone took the time to help me out here!

Thanks!

Quinn



 
 
Søg
Reklame
Statistik
Spørgsmål : 177560
Tips : 31968
Nyheder : 719565
Indlæg : 6408946
Brugere : 218888

Månedens bedste
Årets bedste
Sidste års bedste