I'm new to JavaScript and I have an array of JSON objects with some attributes. I want to sort it by date attribute, which can be either date or bool. I think an example will help you understand my problem.
[
{
"name":"Name 1",
"photoUrl":"URL",
"date" : false,
"bool": false
},
{
"name":"Name2",
"photoUrl":"URL",
"date" : false,
"bool": false
},
{
"name":"Name 3",
"photoUrl":"URL",
"date" : "1.6. 2020",
"bool": true
},
{
"name":"Name 4",
"photoUrl":"",
"date" : "25.9. 2020",
"bool": true
},
{
"name":"Name 5",
"photoUrl":"",
"date" : "29.8. 2020",
"bool": true
},
{
"name":"Name 6",
"photoUrl":"",
"date" : "4.7. 2020",
"bool": true
},
{
"name":"Name 7",
"photoUrl":"",
"date" : "25.6. 2020",
"bool": true
},
{
"name":"Name 8",
"photoUrl":"",
"date" : "22.2. 2021",
"bool": true
},
]
I can change the data structure however I want. Basically, I want the ones with the date not false on top of my array and sorted by the date (newest on top) and then follow with the ones with date false, but I can't find a way to do that.
Thanks much for any help.