fastadmin 默认排序字段是 weigh, 方法是 ajax/weigh
这里以自定义字段 sort 为例

# 根据需要添加对应控制器方法或改写 ajax/weigh 修改 TODO 处

protected $noNeedRight = ['weigh'];
    
    /**
     * 通用排序
     */
    public function weigh()
    {
        // 排序的数组
        $ids = $this->request->post("ids");
        // 拖动的记录 ID
        $changeid = $this->request->post("changeid");
        // 操作字段
        $field = $this->request->post("field");
        // 操作的数据表
        $table = $this->request->post("table");
        if (!Validate::is($table, "alphaDash")) {
            $this->error();
        }
        // 主键
        $pk = $this->request->post("pk");
        // 排序的方式
        $orderway = strtolower($this->request->post("orderway", ""));
        $orderway = $orderway == 'asc' ? 'ASC' : 'DESC';
        $sour = $weighdata = [];
        $ids = explode(',', $ids);
        $prikey = $pk && preg_match("/^[a-z0-9\-_]+$/i", $pk) ? $pk : (model($table)->getPk() ?: 'id');
        $pid = $this->request->post("pid", "");
        //TODO 限制更新的字段
        $field = in_array($field, ['sort']) ? $field : 'weigh';
        // 如果设定了 pid 的值,此时只匹配满足条件的 ID, 其它忽略
        if ($pid !== '') {
            $hasids = [];
            $list = model($table)->where($prikey, 'in', $ids)->where('pid', 'in', $pid)->field("{$prikey},pid")->select();
            foreach ($list as $k => $v) {
                $hasids[] = $v[$prikey];
            }
            $ids = array_values(array_intersect($ids, $hasids));
        }
        $list = model($table)->field("$prikey,$field")->where($prikey, 'in', $ids)->order($field, $orderway)->select();
        foreach ($list as $k => $v) {
            $sour[] = $v[$prikey];
            $weighdata[$v[$prikey]] = $v[$field];
        }
        $position = array_search($changeid, $ids);
        $desc_id = isset($sour[$position]) ? $sour[$position] : end($sour);    // 移动到目标的 ID 值,取出所处改变前位置的值
        $sour_id = $changeid;
        $weighids = array();
        $temp = array_values(array_diff_assoc($ids, $sour));
        foreach ($temp as $m => $n) {
            if ($n == $sour_id) {
                $offset = $desc_id;
            } else {
                if ($sour_id == $temp[0]) {
                    $offset = isset($temp[$m + 1]) ? $temp[$m + 1] : $sour_id;
                } else {
                    $offset = isset($temp[$m - 1]) ? $temp[$m - 1] : $sour_id;
                }
            }
            if (!isset($weighdata[$offset])) {
                continue;
            }
            $weighids[$n] = $weighdata[$offset];
            model($table)->where($prikey, $n)->update([$field => $weighdata[$offset]]);
        }
        $this->success();
    }

# 对应控制器 js - 定义自定义字段排序

// 初始化表格参数配置
            Table.api.init({
                extend: {
                    //...
                    dragsort_url: 'control/tutorial/weigh',
                    table: '',
                }
            });
            Table.config.dragsortfield = 'sort';
            
            // 省略

# 对应 model - 添加记录时,如果未设置排序,自动赋值

protected static function init()
    {
        self::afterInsert(function ($row) {
            $pk = $row->getPk();
            if (!isset($row['sort']) || !$row['sort']) {
                $row->getQuery()->where($pk, $row[$pk])->update(['sort' => $row[$pk]]);
            }
        });
    }