Crontab.php
852 字节
<?php
namespace app\api\controller;
use app\common\controller\Api;
class Crontab extends Api
{
protected $noNeedLogin = ['*'];
protected $noNeedRight = ['*'];
public function index(){
$res = db('study')->field('earn_score')->select();
function sort($res){
$len = count($res);
for ($i = 0; $i < $len - 1; $i++) {//循环比对的轮数
for ($j = 0; $j < $len - $i - 1; $j++) {//当前轮相邻元素循环对比
if ($res[$j] < $res[$j + 1]) {//如果前边的大于后边的
$tmp = $res[$j];//交换数据
$res[$j] = $res[$j + 1];
$res[$j + 1] = $tmp;
}
}
}
return $res;
}
$this->success('',sort($res));
}
}