I am trying to use keys to sort my data from latest to oldest. My first option is to use unique keys in reverse order(latest will be on top), so first I used negative timeStamp as keys. But keys in firebase are string so it won't work. That's why I decided to use [9999999999999 - date.now()] as key in firebase and it works(rendered reversely). Is it safe to use this method? Why using child is the best way to sort data? Why not keys?
firebase.database().ref('saved_phrases')
.child(firebase.auth().currentUser.uid)
.child([9999999999999-Date.now()]).set(
"phrase"
)