0

I am adding a model that has an array of top users.

It is an arraylist of objects.

Everything works just fine, but when viewing the table from the top view it shows the table can't handle right the single digit numbers -

though when actually clicking on that table everything is being shown the correct way -

enter image description here

Is it something internal that has to do with Firebase UI or can I fix it somehow?

Constantin Beer
  • 5,447
  • 6
  • 25
  • 43
Alon Shlider
  • 1,187
  • 1
  • 16
  • 46

1 Answers1

1

Keys in the Firebase Realtime Database are always interpreted as strings, and are sorted lexicographically. In lexicographical order "2" comes after "19", just like "c" comes before "bz".

To work around this problem, you'll typically want to ensure all keys are the same length. When you do that "01" comes before "10". This means you'll have to decide how long your keys can be at most, e.g. "000001" for numbers below a million.


Note that Firebase doesn't use such sequential numbers for its keys for many good reasons. I highly recommend checking out Best Practices: Arrays in Firebase to read more on this.

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807