php中的复杂排序
我一直在与一个复杂的排名系统作斗争。排名取决于学生的分数,而这些分数与分数无关。我对点数的计算没意见。当打破联系时,问题就出现了,因为这取决于学生分数,而学生分数是一个完全不同的实体。学生可以有相似的分数,但分数不同,这可以用来打破平局,以防一些学生在分数上打成平局。我需要帮助,因为我被卡住了。请参考我的照片,以获得一个粗略的想法,并告诉我,如果可以做到这一点。我还包括了我的一些代码php中的复杂排序,php,ranking,Php,Ranking,我一直在与一个复杂的排名系统作斗争。排名取决于学生的分数,而这些分数与分数无关。我对点数的计算没意见。当打破联系时,问题就出现了,因为这取决于学生分数,而学生分数是一个完全不同的实体。学生可以有相似的分数,但分数不同,这可以用来打破平局,以防一些学生在分数上打成平局。我需要帮助,因为我被卡住了。请参考我的照片,以获得一个粗略的想法,并告诉我,如果可以做到这一点。我还包括了我的一些代码 编写一个比较函数来比较标记,并通过比较点来打破联系。然后使用usort使用此函数对$students数组进行排
编写一个比较函数来比较标记,并通过比较点来打破联系。然后使用usort
使用此函数对$students
数组进行排序
function compare_students($s1, $s2) {
$p1 = calculatePoints($s1);
$p2 = calculatePoints($s2);
if ($p1 == $p2) {
return getMarks($s1) - getMarks($s2);
} else {
return $p1 - $p2;
}
}
usort($students, 'compare_students');
编写一个比较函数来比较标记,并通过比较点来打破联系。然后使用usort
使用此函数对$students
数组进行排序
function compare_students($s1, $s2) {
$p1 = calculatePoints($s1);
$p2 = calculatePoints($s2);
if ($p1 == $p2) {
return getMarks($s1) - getMarks($s2);
} else {
return $p1 - $p2;
}
}
usort($students, 'compare_students');
将学生分数作为较小的分数添加到计算点($student\u no)
。e、 g
function calculatePoints($student_no){
/*add this before return it*/
$point = $point*1000;//make sure the new $point be bigger than the max $student_mark
$point += $student_mark;
return $point;
}
跟你现在一样
将学生分数作为较小的分数添加到计算点($student\u no)
。e、 g
function calculatePoints($student_no){
/*add this before return it*/
$point = $point*1000;//make sure the new $point be bigger than the max $student_mark
$point += $student_mark;
return $point;
}
跟你现在一样
你好使用标记打破联系,而使用分数进行排名。我确实尝试了您的代码的修改版本,但在订购那些使用tiedI交换订单的人时仍然存在问题。您好。使用标记打破联系,而使用分数进行排名。我确实尝试了您的代码的修改版本,但在排序那些使用tiedI交换顺序的人时仍然存在问题。