当前位置:网站首页>PHP specified fields are more than 100 in positive order and less than 100 in random order
PHP specified fields are more than 100 in positive order and less than 100 in random order
2022-06-23 15:10:00 【xufengnian_ boke】
$arr = [
[
'id'=>1,
'name'=>'xiaonian',
'time'=>111,
'sort'=>100,
],
[
'id'=>2,
'name'=>'xiaonian',
'time'=>111,
'sort'=>0,
],
[
'id'=>3,
'name'=>'xiaogang',
'time'=>111,
'sort'=>0,
],
[
'id'=>4,
'name'=>'xiaoming',
'time'=>222,
'sort'=>100,
],
[
'id'=>5,
'name'=>'xiaoming',
'time'=>222,
'sort'=>0,
],
];
usort($arr, function($a, $b) {
$day['a'] = $a['time'];
$day['b'] = $b['time'];
if ($day['a'] != $day['b']) {
return strtotime($day['a']) - strtotime($day['b']);
} else {
if ($a['sort'] >= 100 && $b['sort'] >= 100) {
return $a['id'] - $b['id'];
} elseif ($a['sort'] < 100 && $b['sort'] < 100) {
return pow(-1, rand(0,1));
} else {
return $b['sort'] - $a['sort'];
}
}
});
边栏推荐
- Mysql database - log management, backup and recovery
- 《墨者学院——SQL手工注入漏洞测试(MySQL数据库)》
- Error creating bean with name xxx Factory method ‘sqlSessionFactory‘ threw exception; nested excepti
- Helm 基础入门 Helm介绍与安装
- Introduction to helm basics helm introduction and installation
- 港股今年最大IPO来了,660亿身家,坐在矿山上的“大王”
- Logistics trade related
- 2021-05-22
- RF Analyzer Demo搭建
- An idea plug-in for automatically generating unit tests
猜你喜欢

ICML 2022 𞓜 context integrated transformer based auction design neural network

建议自查!MySQL驱动Bug引发的事务不回滚问题,也许你正面临该风险!

Self inspection is recommended! The transaction caused by MySQL driver bug is not rolled back. Maybe you are facing this risk!

Summary of operating system underlying knowledge (interview)

知名人脸搜索引擎惹众怒:仅需一张照片,几秒钟把你扒得底裤不剩

AXI_Round_Robin_Arbiter 设计 - AW、W通道部分

山东:美食“隐藏款”,消费“扫地僧”

KDD'22「阿里」推荐系统中的通用序列表征学习
![[in depth understanding of tcapulusdb technology] tcapulusdb construction data](/img/0c/33d9387cd7733a0c6706a73f9535f7.png)
[in depth understanding of tcapulusdb technology] tcapulusdb construction data

Distributed database uses logical volume to manage storage expansion
随机推荐
Babbitt | metauniverse daily must read: meta, Microsoft and other technology giants set up the metauniverse Standards Forum. Huawei and Alibaba joined. NVIDIA executives said that they welcomed partic
Volatile~ variables are not visible under multithreading
打印内存站信息
信贷产品额度定价场景下的回归模型效果评估
列表查询排序参数处理
微信小程序引导用户添加小程序动画页
PHP指定字段大于100正序排,小于100随机排
Selenium Edge的IE模式
Self inspection is recommended! The transaction caused by MySQL driver bug is not rolled back. Maybe you are facing this risk!
【opencv450】椒盐噪声demo
TS encapsulation request
2021-04-15
系统设计与分析课程项目个人小结
MySQL create and manage tables
How to make food nutrition label
An idea plug-in for automatically generating unit tests
中国矿大团队,开发集成多尺度深度学习模型,用于 RNA 甲基化位点预测
SFOD:无源域适配升级优化,让检测模型更容易适应新数据(附论文下载)
Logistics trade related
2021-06-07