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 ofkey 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 >