I have the following data structure which I want to sort by uploaded_on, where the newest timestamp comes first:
"hd2CnPPZ5FMKjpzFJNUc4xVLVUW2" : {
"media" : {
"-KJkxpnRg_2ZK4tEjGBN" : {
"uploaded_on" : 1465405365513,
"url" : "<my-firebase-storage-url>"
},
And I have the following code to retrieve the data and sort it:
FIREBASE_REF.database().ref(`${this.props.auth.user.uid}/media`).orderByChild('uploaded_on').on('value', (snapshot) => {
this.props.dispatch(mediaActions.updateMedia(snapshot.val()));
});
However, my items do not get ordered properly and the the oldest timestamp comes first. I tried by putting a minus infront of the uploaded_on, but that does not make any difference.
Any pointers in what I'm doing wrong?