aboutsummaryrefslogtreecommitdiff
path: root/src/fscore.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/fscore.php')
-rw-r--r--src/fscore.php42
1 files changed, 30 insertions, 12 deletions
diff --git a/src/fscore.php b/src/fscore.php
index 9687058..9d24d83 100644
--- a/src/fscore.php
+++ b/src/fscore.php
@@ -36,31 +36,49 @@ function ScoreCMP($a,$b) {
}
if ($a["user"]<$b["user"]) return 1;
else if ($a["user"]>$b["user"]) return -1;
- else return 0;
+ else {
+ if ($a["site"]<$b["site"]) return 1;
+ else if ($a["site"]>$b["site"]) return -1;
+ else return 0;
+ }
}
}
}
function ordena($a) {
+ $n = count($a);
+ /*
$r = array();
- for ($i=0; $i<count($a); $i++) {
+ for ($i=0; $i<$n; $i++) {
$max=null;
- reset($a);
- while ( list ($e, $c) = each($a) ) {
- if ($a[$e]!=null && ($max==null || ScoreCMP($a[$e],$max) > 0)) {
- $j=0;
- for(;$j<$i;$j++)
- if($r[$j]['user']==$a[$e]['user'] && $r[$j]['site']==$a[$e]['site']) break;
- if($j>=$i) {
- $max = $a[$e];
+ foreach($a as $e => $c) {
+ if ($c != null && ($max==null || ScoreCMP($c,$max) > 0)) {
+ // $j=0;
+ // for(;$j<$i;$j++)
+ // if($r[$j]['user']==$a[$e]['user'] && $r[$j]['site']==$a[$e]['site']) break;
+ // if($j>=$i) {
+ $max = $c;
$maxe = $e;
- }
+ // }
}
}
if ($max==null) break;
$r[$i] = $max;
$a[$maxe] = null;
}
- return $r;
+ */
+ uasort($a, "ScoreCMP");
+ $j = 0;
+ $r = array();
+ foreach($a as $k) {
+ if($j == 0) $r[0] = $k;
+ else {
+ if($k['user'] != $r[$j]['user'] || $k['site'] != $r[$j]['site']) {
+ $j++;
+ $r[$j] = $k;
+ }
+ }
+ }
+ return $r;
}
function DBScore($contest, $verifylastmile, $hor=-1, $globalsite='0') {
$c = DBConnect();