so I try to sort data from with most likes to the least. How do I do that if don't have an object name? because currently I only have the ID of the object?
here's my Firebase json:
["-KfSODzRPjy46ayCFRBH": {
"_createdAt" = 1489773065234;
"_updatedAt" = 1489773065234;
content = (
"<null>",
Tittle,
"why not there is the nnnd ksksks lalalalalkdkdkdkdk kadsjfakl;",
whhhhhhalalallala
);
imageTitle = 1489773064177;
like = 2;
title = "Third Post";
},
["-KfSODzRPjy46ayCFRBH": {
"_createdAt" = 1489773065234;
"_updatedAt" = 1489773065234;
content = (
"<null>",
Tittle,
"why not there is the nnnd ksksks lalalalalkdkdkdkdk kadsjfakl;",
whhhhhhalalallala
);
imageTitle = 1489773064177;
like = 3;
title = "Third Post";
},
this is how I read:
let handleref = databaseRef.child("v1/postmodel").observe(.value, with: { (snapshot) in
let postDict = snapshot.value as! [String : AnyObject]
print(postDict)
})