Crontab.php 976 字节
<?php

namespace app\api\controller;


use app\common\controller\Api;

/**
 * 定时任务
 * @ApiWeigh    (94)
 */
class Crontab extends Api
{
    protected $noNeedLogin = ['*'];
    protected $noNeedRight = ['*'];


    /**
     * @ApiTitle (首页)
     */
    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));
    }
}