|
@@ -12,9 +12,20 @@ class Crontab extends Api |
|
@@ -12,9 +12,20 @@ class Crontab extends Api |
12
|
|
12
|
|
13
|
|
13
|
|
14
|
public function index(){
|
14
|
public function index(){
|
15
|
- $res = db('study')->field('team_id,earn_score,team_rank')->select();
|
|
|
16
|
- if ($res['team_id']){
|
|
|
17
|
-
|
15
|
+ $res = db('study')->field('earn_score')->select();
|
|
|
16
|
+ function sort($res){
|
|
|
17
|
+ $len = count($res);
|
|
|
18
|
+ for ($i = 0; $i < $len - 1; $i++) {//循环比对的轮数
|
|
|
19
|
+ for ($j = 0; $j < $len - $i - 1; $j++) {//当前轮相邻元素循环对比
|
|
|
20
|
+ if ($res[$j] < $res[$j + 1]) {//如果前边的大于后边的
|
|
|
21
|
+ $tmp = $res[$j];//交换数据
|
|
|
22
|
+ $res[$j] = $res[$j + 1];
|
|
|
23
|
+ $res[$j + 1] = $tmp;
|
|
|
24
|
+ }
|
|
|
25
|
+ }
|
|
|
26
|
+ }
|
|
|
27
|
+ return $res;
|
18
|
}
|
28
|
}
|
|
|
29
|
+ $this->success('',sort($res));
|
19
|
}
|
30
|
}
|
20
|
} |
31
|
} |