1

When I add the JSON file to Firebase all the data gets arranged randomly

Note:- for some issues previously I don't have any parent node, so what I mean is that after the root node there are all child nodes

here is the json

here is the database arranged randomly and not according to the JSON format

enter image description here enter image description here

as you can see the quotes are not arranged in numerical order,how my JSON is

what should I do and please give a solution without adding a parent node because it is creating other difficulties

Alex Mamo
  • 130,605
  • 17
  • 163
  • 193

1 Answers1

0

When I add the JSON file to Firebase all the data gets arranged randomly.

That's not a random order. By default, all the nodes in the Firebase Console are ordered by key. Unfortunately, there is no way you can change that order. Please note that the keys are always strings. And when strings are ordered, the order is lexicographically. This means that it doesn't consider any sort of numeric values when sorting.

That being said, if you order numbers, this is the normal order:

  • 1
  • 9
  • 10
  • 11

But when it comes to strings, the order is:

  • "1"
  • "11"
  • "19"
  • "9"

Where 19 comes before 9.

If you want to change this behavior, please check my answer in the following post:

Alex Mamo
  • 130,605
  • 17
  • 163
  • 193