Project Detail

PHP Comparison Function  

PHP Comparison Function is project number 412572
posted at Freelancer.com. Click here to post your own project.

 

| More Free Trial For New Buyers
 

Status:

Selected Providers: kraynyukov

Budget: $30-250

Created: 04/02/2009 at 21:10 EDT

Bid Count: 13

Average Bid:
$ 68

04/05/2009 at 21:10 EDT

Project Creator: fanfavorite
Employer Rating: 10/1010/1010/1010/1010/1010/1010/1010/1010/1010/10 (5 reviews)

Bid On This Project
 

Description

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']<$ar2['pts']) {
return 1;
} elseif ($ar1['pts']>$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']<$ar2['w']) {
return 1;
} else if ($ar1['w']>$ar2['w']) {
return -1;
}
if (($ar1['gf'] - $ar1['ga']) < ($ar2['gf'] - $ar2['ga'])) {
return 1;
} elseif (($ar1['gf'] - $ar1['ga']) > ($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 > ($ar2['gf'] + $ar2['ga']) / $arg2) {
return 1;
} elseif (($ar1['gf'] + $ar1['ga']) / $arg1 < ($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.


Additional information submitted:

04/02/2009 at 22:28 EDT:
Check out the attached PDF for additional information and array details.

04/03/2009 at 10:13 EDT:
I have revised the array to include all missing information.


Additional files submitted:
Sort By Points.pdf
Sort By Points_revised.pdf

Job Type

Messages Posted:1 View project clarification board Post message on project clarification board

Bid On This Project
 

If you are the project creator or one of the bidders Log In for more options

 

75

0 days

04-03-2009 02:45 EDT

Get it solved... Thanks

help

 

45

0 days

04-03-2009 02:40 EDT

I can do this easily. Please contact if interested.

help

 

50

1 day

04-03-2009 00:35 EDT

We can do it

help

 

50

0 days

04-02-2009 21:22 EDT

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

help

 

100

0 days

04-03-2009 01:27 EDT

Hi, Please check your PM. Regards,

help

 

50

0 days

04-03-2009 08:59 EDT

Please check PMB. Thanks.

help

 

200

1 day

04-03-2009 08:19 EDT

Please read PM for details.

help

 

50

1 day

04-03-2009 01:17 EDT

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

help

 

35

0 days

04-03-2009 00:44 EDT

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

help

 

100

4 days

04-03-2009 10:27 EDT

I can do it for you.please accept my bid

help

 

35

0 days

04-03-2009 00:35 EDT

(No Feedback Yet)

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

help

 

45

1 day

04-03-2009 05:40 EDT

(No Feedback Yet)

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

help

 

50

1 day

04-03-2009 10:11 EDT

(No Feedback Yet)

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

help


    Bid on this Project