I have an array :
var array = [
{ID : 1,
Name : one,
data : {more info here}
},
{ID : 2,
Name : two
},
{ID : 3,
Name : three,
data : {more info here}
},
{ID : 4,
Name : four
},
{ID : 5,
Name : five,
data : {more info here}
},]
Need to sort these array, where data is present will be top, then other. Final sort result will be -
[{ID:1,name: one,data: {}},
{ID:3,name: three,data: {}},
{ID:5,name: five,data: {}},
{ID:2,name: two},
{ID:4,name: four}]
datafirst, sorted in increasingIDorder, then all those withoutdataalso sorted in increasingIDorder?datashould be before all those withoutdataand you don't care what order they are in within those two groups, then providing randomized input might not matter. In other words, if the array result is OK if theIDs are in the order[5,1,3,4,2], then this might not matter?ID(i.e. your question implies that this may be the case, but is not clear). If you clarify that you either do, or do not, care about the order ofIDwithin the havedata/not havedatasubgroups, I will remove my down vote. If you do clarify this (one way or the other), please leave a comment with@Makyenin it so I am notified to come back and take a look.