# PHP Comparison Function

I have a stats comparison sort function for stats using PHP's uasort. This works well with 2 teams however if more than 2 teams are tied, I need to be able to run a number of tie breaking rules. The function right now is:

function Compare_standings(\$ar1, \$ar2){

if (\$ar1['pts']&lt;\$ar2['pts']) {

return 1;

} elseif (\$ar1['pts']&gt;\$ar2['pts']) {

return -1;

}

if (in_array(\$ar1['id'],\$ar2['teamsbeat'])) {

return 1;

} elseif (in_array(\$ar2['id'],\$ar1['teamsbeat'])) {

return -1;

}

if (\$ar1['w']&lt;\$ar2['w']) {

return 1;

} else if (\$ar1['w']&gt;\$ar2['w']) {

return -1;

}

if ((\$ar1['gf'] - \$ar1['ga']) &lt; (\$ar2['gf'] - \$ar2['ga'])) {

return 1;

} elseif ((\$ar1['gf'] - \$ar1['ga']) &gt; (\$ar2['gf'] - \$ar2['ga'])) {

return -1;

}

if (\$ar1['ga'] == 0) {

\$arg1 = 1;

} else {

\$arg1 = \$ar1['ga'];

}

if (\$ar2['ga'] == 0) {

\$arg2 = 1;

} else {

\$arg2 = \$ar2['ga'];

}

if ((\$ar1['gf'] + \$ar1['ga']) / \$arg1 &gt; (\$ar2['gf'] + \$ar2['ga']) / \$arg2) {

return 1;

} elseif ((\$ar1['gf'] + \$ar1['ga']) / \$arg1 &lt; (\$ar2['gf'] + \$ar2['ga']) / \$arg2) {

return -1;

}

return 0;

}

uasort(\$tstats['tm'], 'Compare_standings');

What I need to happen is add the ability to compare additional variables if 3 or more are tied. So say a team has the same amount of points as 2 other teams, it needs to go through a number of rules based on the 3 values, not just 2.

Check out the attached PDF for additional information and array details.

I have revised the array to include all missing information.

Taidot: PHP

Tietoa työnantajasta:
( 5 arvostelua ) Ajax, Canada

Projektin tunnus: #412572

## Myönnetty käyttäjälle:

kraynyukov

\$50 USD 0 päivässä
(12 Arvostelua)
5.0

## 13 freelanceria on tarjonnut keskimäärin %project_bid_stats_avg_sub_26% %project_currencyDetails_sign_sub_27% tähän työhön

lightcresent

Get it solved... Thanks

\$75 USD 0 päivässä
(481 arvostelua)
9.0
soner

\$45 USD 0 päivässä
(121 arvostelua)
8.1
naumanrandhawa

Its so simple to do. I am expert in php,c++ aand may more. its a simple loogic to be implemented. i can do it for you in a very reasonble amount thanx. check pmb

\$35 USD 0 päivässä
(153 arvostelua)
7.4
momleetech

We can do it

\$50 USD 1 päivässä
(104 arvostelua)
6.7
karmu

hi i am an expert developer from japan . with work experience of 9 year in PHP/Mysql. i am interested for the project. lets do it. Thanks

\$50 USD 0 päivässä
(62 arvostelua)
6.0
hieutc

\$100 USD 0 päivässä
(23 arvostelua)
5.8
murza

\$200 USD 1 päivässä
(11 arvostelua)
5.0
sublimecode

This sounds like fun. I have 4+ years experience in PHP development.

\$50 USD 1 päivässä
(8 arvostelua)
4.0
travo

Hi, I am interested and can easily make this function happen. Please see the PMB. Thanks

\$35 USD 0 päivässä
(3 arvostelua)
2.4
MichaelHuang

hi,i am a professional PHP developer,i can help you to improve this function.

\$45 USD 1 päivässä
(1 arvostelu)
0.0
ayandisharingan

i can handle that if you are interest write me to ayandi_lemus from yahoo dot com

\$50 USD 1 päivässä
(0 arvostelua)
0.0
sivakotamraj

I can do it for [login to view URL] accept my bid

\$100 USD 4 päivässä
(0 arvostelua)
0.0