How to change the ordering of js objects?

how to change the order of objects when using numeric strings as key?

let obj = {

2015: [
    {
        "title": "1"
        "sum": "1"
    },
    {
        "title": "2"
        "sum": "2"
    }
],
2016: [
    {
        "title": "3"
        "sum": "3"
    }
],
2017: [
    {
        "title": "4"
        "sum": "4"
    }
]

}

When the value of

key is a numeric string, the default sort is always from small to large. I convert objects into an array and then sort them in reverse order, and the result is still sorted from small to large.

because the list data I render needs to be sorted from large to small? Is there any other way to solve it?

< div class= "item" >

<strong>2017</strong>
<ul>
    <li>4<span>4</span></li>
</ul>

< / div >

< div class= "item" >

<strong>2016</strong>
<ul>
    <li>3<span>3</span></li>
</ul>

< / div >

< div class= "item" >

<strong>2015</strong>
<ul>
    <li>1<span>1</span></li>
    <li>2<span>2</span></li>
</ul>

< / div >

Aug.01,2021

1. Read key into array
2. Sort
3. Loop array, reads values in order and operates
example


json data is out of order, not for sorting, but for query, it is just a small hash table! It's only available in arrays. Don't bother!


Object.keys (obj). Sort ((answer b) > Amurb)
get the key of the sorted object after traversing the key to get the value of the object. If it is not correct, change it to bMui a try


you convert the object to array sorting, and the object already has a default sort.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b40cdf-41583.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b40cdf-41583.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?