当前位置:网站首页>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主从只同步部分库或表的思路与方法
- Helm 基础入门 Helm介绍与安装
- 【opencv450】椒盐噪声demo
- 百万奖金等你来拿,首届中国元宇宙创新应用大赛联合创业黑马火热招募中!
- 【二级等保】过二级等保用哪个堡垒机品牌好?
- ACM Player Illustration leetcode remove element
- [deeply understand tcapulusdb technology] tcapulusdb import data
- Mysql双主配置的详细步骤
- 建议自查!MySQL驱动Bug引发的事务不回滚问题,也许你正面临该风险!
- Résumé de la méthode de déduction de la force 513 - trouver la valeur du coin inférieur gauche de l'arbre
猜你喜欢

2021-05-08
mysql主从只同步部分库或表的思路与方法

中国矿大团队,开发集成多尺度深度学习模型,用于 RNA 甲基化位点预测

从3开始,在业务系统中增加分页功能

《墨者学院——SQL手工注入漏洞测试(MySQL数据库)》

k8s--部署单机版MySQL,并持久化

Illustration of ONEFLOW's learning rate adjustment strategy

【DataHub】LinkedIn DataHub学习笔记

How can genetic testing help patients fight disease?

ICML 2022 𞓜 context integrated transformer based auction design neural network
随机推荐
Summary of operating system underlying knowledge (interview)
腾讯云服务器发送邮件失败
The team of China University of Mines developed an integrated multi-scale deep learning model for RNA methylation site prediction
Effect evaluation of regression model under credit product quota pricing scenario
Sectigo(Comodo)证书的由来
The new version of Alibaba Seata finally solves the idempotence, suspension and empty rollback problems of the TCC mode
Raspberry PI installing the wiring pi
JS垃圾回收
用OBS做直播推流简易教程
KDD'22「阿里」推荐系统中的通用序列表征学习
【深入理解TcaplusDB技術】TcaplusDB構造數據
AI intelligent robot saves us time and effort
详解Redis分布式锁的原理与实现
MySQL高级语句二
Idea view View the class file idea Class folder
从3开始,在业务系统中增加分页功能
Golang-- judge whether the strings are equal
MySQL advanced statement 2
2021-05-08
进销存软件排行榜前十名!