I'm new to JavaScript and I'm trying to work with JSON object I got from an API and I'm trying to find a way how to sort it by bool value inside. I had a feeling that this will be already answered the question, but I can't find a way to do it my way.
Here is my response (It's my API so I can change data types and add values if needed)
[
{
"name":"Name 1",
"photoUrl":"Photo url 1",
"bool": false
},
{
"name":"Name 2",
"photoUrl":"Photo url 2",
"bool": false
},
{
"name":"Name 3",
"photoUrl":"Photo url 3",
"bool": true
},
{
"name":"Name 4",
"photoUrl":"Photo url 4",
"bool": false
},
{
"name":"Name 5",
"photoUrl":"Photo url 5",
"bool": true
}
]
I want to have objects with bool: true on top, and those with bool: false on bottom.
I couldn't find a way to do it myself. I appreciate any help.