当前位置:网站首页>字符串时间排序,对时间格式字符串进行排序
字符串时间排序,对时间格式字符串进行排序
2022-06-10 22:57:00 【卸载引擎】
let arr = [
{
time: '2021/08/10 20:18'},
{
time: '2021/08/10 05:18'},
{
time: '2021/07/10 14:18'},
{
time: '2021/08/13 14:05'},
{
time: '2021/08/01 20:18'},
{
time: '2021/09/10 20:18'},
{
time: '2021/09/05 20:18'},
]
// 对这个数组按时间升序排列,即最近的时间显示在最后, 如下:
arr = arr.sort(
(a,b) => new Date(a.time).getTime() - new Date(b.time).getTime()
);
使用
Object.keys(dataSources).sort((a, b) => {
return new Date(a).getTime() - new Date(b).getTime()
}).map(item => {
obj[item] = dataSources[item]
});

边栏推荐
- mybaits merge into
- MultipartFile重命名上传
- 【漫天烟花】绚烂烟花点亮夜空也太美了叭、某程序员携带烟花秀给大家拜年啦~
- How to check the variable waveform when debugging the program? Look here
- 【AI出牌器】第一次见这么“刺激”的斗地主,胜率高的关键因素竟是......
- [opencv practice] in cold winter, there will be a rainbow. Do you love this special effect?
- [auto reply or remind assistant] Mom doesn't have to worry about me missing messages any more (10 Line Code Series)
- 选择排序
- Njupt Nanyou Discrete Mathematics_ Experiment 2
- Struggle, programmer -- Chapter 56: hard work with thousands of blows
猜你喜欢

SystemVerilog (x) - user defined type

【Pygame小游戏】《坦克大战》,那些童年的游戏你还记得几个呢?
![[turtle confessions collection]](/img/97/6f1008386931bcb93655d94121e2c4.png)
[turtle confessions collection] "the moon at the bottom of the sea is the moon in the sky, and the person in front of us is the sweetheart." Be happy for the rest of your life, and be safe for ever ~

【Pygame小游戏】来了来了它来了——这款五子棋小游戏超A的,分享给你的小伙伴儿一起pk吧~

Difference between oscilloscope and spectrum analyzer

【Pygame小游戏】别找了,休闲游戏专题来了丨泡泡龙小程序——休闲游戏研发推荐

【Pygame小游戏】“史上最炫酷贪吃蛇”驾到,FUN开玩(不好玩不要钱)

【AcWing】4. Multiple knapsack problem I

Basic operation of OpenCV actual combat image: this effect amazed everyone (with code analysis)

Wireshake introduction learning notes
随机推荐
Select sort
快速排序
In the month of safety production, Huangpu launched a publicity campaign for gas safety in shops
curl导入postman报错小记
【Pygame小游戏】首月破亿下载 一款高度融合了「超休闲游戏特性」的佳作~
[pyGame games] don't look for it. Here comes the leisure game topic - bubble dragon widget - recommendation for leisure game research and development
[MVC&Core]ASP.NET Core MVC 视图传值入门
VTK例子--三個相交的平面
[pyGame] this classic bomber super game is online. Do you love it? (source code attached)
对接请求方式
【自动回复or提醒小助手】妈妈再也不用担心我漏掉消息了(10行代码系列)
sql 语句--输入 月份 查日期(年月日),输出 月份
【JVM】内存模型
[turtle confessions collection] "the moon at the bottom of the sea is the moon in the sky, and the person in front of us is the sweetheart." Be happy for the rest of your life, and be safe for ever ~
Bluetooth development (11) -- ble interacts happily
Chapter 2 application layer 2.4 DNS
什么是绝对和相对路径,有哪些优缺点?
452. 用最少数量的箭引爆气球
[JVM] thread
静态方法static学习