版权声明:学习交流QQ群:136242956,知识共享署名-非商业性使用-禁止演绎 3.0 未本地化版本许可协议-进行许可。 https://blog.csdn.net/xzykai/article/details/81133614
正如你所看到的,Collection 类允许你使用方法链对底层数组执行匹配和移除操作,通常,每个 Collection 方法都会返回一个新的 Collection 实例。
//构建collect对象根据priority_index字段正序排
$book1 = collect($arr)->sortBy('priority_index');
//构建collect对象根据priority_index字段倒序排
$book = collect($arr)->sortByDesc('priority_index');