I want to get sorted data as.... value1--value2--value3....value10--value11
Asked
Active
Viewed 44 times
-5

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

Amit Saxena
- 1
- 1
-
Do Arraylist sort . – IntelliJ Amiya Sep 14 '17 at 10:29
-
You'll have to sort an arrayList by overridding the comparator to match your requirements. – Alexandre BOURETZ Sep 14 '17 at 10:30
-
is there any way to get data from firebase as value1--value2--value3....value10--value11... I dont want to sort arraylist – Amit Saxena Sep 14 '17 at 10:33
1 Answers
1
String values are sorted lexicographically. If you want them to be sorted in the order you want, you'll need to ensure that the lexicographical order matches your needs, e.g. pad the numbers in your keys to all be the same length:
"value01": ...
..
"value09": ...
"value10": ...
I wrote a longer answer on this a while ago, see: Firebase query ordering not working properly

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