Reputation: 104
I'm missing something or Fireabase just isn't sorting at all ??
https://dinosaur-facts.firebaseio.com/dinosaurs.json?orderBy=%22height%22&print=pretty
{
"bruhathkayosaurus" : {
"appeared" : -70000000,
"height" : 25,
"length" : 44,
"order" : "saurischia",
"vanished" : -70000000,
"weight" : 135000
},
"lambeosaurus" : {
"appeared" : -76000000,
"height" : 2.1,
"length" : 12.5,
"order" : "ornithischia",
"vanished" : -75000000,
"weight" : 5000
},
"linhenykus" : {
"appeared" : -85000000,
"height" : 0.6,
"length" : 1,
"order" : "theropoda",
"vanished" : -75000000,
"weight" : 3
},
"pterodactyl" : {
"appeared" : -150000000,
"height" : 0.6,
"length" : 0.8,
"order" : "pterosauria",
"vanished" : -148500000,
"weight" : 2
},
"stegosaurus" : {
"appeared" : -155000000,
"height" : 4,
"length" : 9,
"order" : "ornithischia",
"vanished" : -150000000,
"weight" : 2500
},
"triceratops" : {
"appeared" : -68000000,
"height" : 3,
"length" : 8,
"order" : "ornithischia",
"vanished" : -66000000,
"weight" : 11000
}
}
The heights are not sorted, is returning [44,...,0.6,...,3]
Upvotes: 0
Views: 359
Reputation: 58400
The request returns the result as a JSON object and there is no way to express the ordering, so the orderBy
parameter cannot be used for ordering the results.
The orderBy
parameter is expected to be used in conjunction with filtering parameters like equalTo
.
See also this answer.
Upvotes: 4