# How to get a very long list from firebase and sort it

**URL:** <https://community.thunkable.com/t/how-to-get-a-very-long-list-from-firebase-and-sort-it/1084780>\
**Category:** Questions about Thunkable X\
**Created:** [February 6, 2021, 12:40pm UTC](https://community.thunkable.com/t/how-to-get-a-very-long-list-from-firebase-and-sort-it/1084780 "2021-02-06T12:40:08Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![funhall](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/funhall/32/92145_2.png) [@funhall](https://community.thunkable.com/u/funhall)\
**Post date:** [February 6, 2021, 12:40pm UTC](https://community.thunkable.com/t/how-to-get-a-very-long-list-from-firebase-and-sort-it/1084780/1 "2021-02-06T12:40:08Z")

</div>

Hi all Thunkers.

I have a very long list between 300 and 400 lines. And i like to get all text in the ap ones so I can sort it.  
How can I do that in the best way. I need to find the customers near you from the list. So it is way to heavy if I need to go out on firebase with the Clod variable for each customer. That takes way to long time.  
Hope you know what I mean.  
I need the magic keyward to do this the fastest way, thanks.  
Keep safe.

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/9/6/966c7a0eb27cd291dcf512aa6adb326784ff3ba5.png)

---

<div class="post-metadata">

**Author:** ![drted](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/drted/32/92694_2.png) [@drted](https://community.thunkable.com/u/drted)\
**Post date:** [February 6, 2021, 1:25pm UTC](https://community.thunkable.com/t/how-to-get-a-very-long-list-from-firebase-and-sort-it/1084780/3 "2021-02-06T13:25:24Z")

</div>

Simply set an App variable to the Firebase node you are interested in searching. It is surprisingly fast. Then you can searh/sort using the app variable. I’ve pulled Firebase JSON trees with over 30,000 nodes without any problems.

To sort a JSON list, check out [More JSON - Sort Object List by Object Property](https://community.thunkable.com/t/more-json-sort-object-list-by-object-property/904479).

I believe @muneer also has a search/sort solution.

---

<div class="post-metadata">

**Author:** ![funhall](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/funhall/32/92145_2.png) [@funhall](https://community.thunkable.com/u/funhall)\
**Post date:** [February 6, 2021, 1:27pm UTC](https://community.thunkable.com/t/how-to-get-a-very-long-list-from-firebase-and-sort-it/1084780/4 "2021-02-06T13:27:16Z")

</div>

Thank you so much. I am not sure what you mean by Firebase node. To get all text from the database. Can you show me the block to to that please?

---

<div class="post-metadata">

**Author:** ![drted](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/drted/32/92694_2.png) [@drted](https://community.thunkable.com/u/drted)\
**Post date:** [February 6, 2021, 1:30pm UTC](https://community.thunkable.com/t/how-to-get-a-very-long-list-from-firebase-and-sort-it/1084780/5 "2021-02-06T13:30:26Z")

</div>

![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/f/e/febe74c38b4fb13356212e5539f7b66715d046f0.png)

---

<div class="post-metadata">

**Author:** ![funhall](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/funhall/32/92145_2.png) [@funhall](https://community.thunkable.com/u/funhall)\
**Post date:** [February 6, 2021, 1:34pm UTC](https://community.thunkable.com/t/how-to-get-a-very-long-list-from-firebase-and-sort-it/1084780/6 "2021-02-06T13:34:24Z")

</div>

Thanks have tryed that.  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/9/8/9840ee7370cfeeae8f434e08d5b8dd84cdf0592b.png)  
This way it is undefined

---

<div class="post-metadata">

**Author:** ![funhall](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/funhall/32/92145_2.png) [@funhall](https://community.thunkable.com/u/funhall)\
**Post date:** [February 6, 2021, 1:38pm UTC](https://community.thunkable.com/t/how-to-get-a-very-long-list-from-firebase-and-sort-it/1084780/7 "2021-02-06T13:38:05Z")

</div>

in this way I just get the numbers (index)

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/f/7/f75c9fc0654c3e411d53621ebd4279708a071814.png) of each customer

---

<div class="post-metadata">

**Author:** ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)\
**Post date:** [February 6, 2021, 1:39pm UTC](https://community.thunkable.com/t/how-to-get-a-very-long-list-from-firebase-and-sort-it/1084780/8 "2021-02-06T13:39:29Z")

</div>

Use this to see your DB entries as text  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/b/f/bfa96d7bd512390f38b15b769f2a0b116fc7b4a8.png)

---

<div class="post-metadata">

**Author:** ![drted](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/drted/32/92694_2.png) [@drted](https://community.thunkable.com/u/drted)\
**Post date:** [February 6, 2021, 1:40pm UTC](https://community.thunkable.com/t/how-to-get-a-very-long-list-from-firebase-and-sort-it/1084780/9 "2021-02-06T13:40:18Z")

</div>

![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/7/a/7aab98437929fca6bcd3ad8017783bc8cb8f60d5.png)

---

<div class="post-metadata">

**Author:** ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)\
**Post date:** [February 6, 2021, 1:45pm UTC](https://community.thunkable.com/t/how-to-get-a-very-long-list-from-firebase-and-sort-it/1084780/10 "2021-02-06T13:45:17Z")

</div>

From your data sample you can use something like this to retrieve `title` of the first entry

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/8/d/8dde7ed3fe57858ae184ee1087db09e27858056b.png)

This is just an example

---

<div class="post-metadata">

**Author:** ![funhall](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/funhall/32/92145_2.png) [@funhall](https://community.thunkable.com/u/funhall)\
**Post date:** [February 6, 2021, 1:45pm UTC](https://community.thunkable.com/t/how-to-get-a-very-long-list-from-firebase-and-sort-it/1084780/11 "2021-02-06T13:45:36Z")

</div>

I dont think I can do it like that. Because I have several 100 customers in every city I have. So  
like @drted surgest i need a “Create objec twith field block” with tilte, handle, latitude and longitude for each customer in each city. And that will never be the same numbers. Am I right?

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/2/2/2208d3699e0a40ad701bee5d4debf8210b142bf0.png)

---

<div class="post-metadata">

**Author:** ![funhall](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/funhall/32/92145_2.png) [@funhall](https://community.thunkable.com/u/funhall)\
**Post date:** [February 6, 2021, 1:49pm UTC](https://community.thunkable.com/t/how-to-get-a-very-long-list-from-firebase-and-sort-it/1084780/12 "2021-02-06T13:49:36Z")

</div>

Sorry to say but this bive the result “undefined”

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/e/f/ef36ef833ecaebeb1b3c338124a46153d3e6271b.png)

---

<div class="post-metadata">

**Author:** ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)\
**Post date:** [February 6, 2021, 1:53pm UTC](https://community.thunkable.com/t/how-to-get-a-very-long-list-from-firebase-and-sort-it/1084780/13 "2021-02-06T13:53:52Z")

</div>

Why do you need to use indirect assignment to the `app variables`?

In my example I use the normal (basic type of app variable) to store the DBCopy and then use it to get the info.

Try using the normal app variables now to make it easier to test.

---

<div class="post-metadata">

**Author:** ![drted](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/drted/32/92694_2.png) [@drted](https://community.thunkable.com/u/drted)\
**Post date:** [February 6, 2021, 1:55pm UTC](https://community.thunkable.com/t/how-to-get-a-very-long-list-from-firebase-and-sort-it/1084780/14 "2021-02-06T13:55:44Z")

</div>

Here is a simple way to search the local tree for a value.

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/0/e/0e39df831b6e18b0d9fe382f0649eb837de99f7d.png)

Finding the “closest” customer based on latitude and longitude is difficult in Thunkable. Here is a link to one of many discussion of the problem. [Loading Map Markers Near User](https://community.thunkable.com/t/loading-map-markers-near-user/598411).

---

<div class="post-metadata">

**Author:** ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)\
**Post date:** [February 6, 2021, 1:59pm UTC](https://community.thunkable.com/t/how-to-get-a-very-long-list-from-firebase-and-sort-it/1084780/15 "2021-02-06T13:59:16Z")

</div>

You spelled “title” wrong. This is why you got `undefined`

![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/0/d/0dcdbbde54729f42ecec0dabab84dc9d53d8185f.png)  
see your block.

---

<div class="post-metadata">

**Author:** ![funhall](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/funhall/32/92145_2.png) [@funhall](https://community.thunkable.com/u/funhall)\
**Post date:** [February 6, 2021, 2:01pm UTC](https://community.thunkable.com/t/how-to-get-a-very-long-list-from-firebase-and-sort-it/1084780/16 "2021-02-06T14:01:00Z")

</div>

Thanks i also notised that. So I am back on track. But how is it to get the longitude and latitude that is in the child Address

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/8/d/8d5290baf778013ea8544a3a05be751f3e2a3e44.png)  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/1/d/1d7eddd4de65605070ca93bb79c4ca252c05667c.png)

---

<div class="post-metadata">

**Author:** ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)\
**Post date:** [February 6, 2021, 2:02pm UTC](https://community.thunkable.com/t/how-to-get-a-very-long-list-from-firebase-and-sort-it/1084780/17 "2021-02-06T14:02:29Z")

</div>

Place them the other way round in the block. latitude first then address.

---

<div class="post-metadata">

**Author:** ![funhall](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/funhall/32/92145_2.png) [@funhall](https://community.thunkable.com/u/funhall)\
**Post date:** [February 6, 2021, 2:05pm UTC](https://community.thunkable.com/t/how-to-get-a-very-long-list-from-firebase-and-sort-it/1084780/18 "2021-02-06T14:05:21Z")

</div>

yes like this right?

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/4/1/41a0474145259906a44b2e7e1e12144e6ea673b8.png)  
But the app crashes all the time

---

<div class="post-metadata">

**Author:** ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)\
**Post date:** [February 6, 2021, 2:10pm UTC](https://community.thunkable.com/t/how-to-get-a-very-long-list-from-firebase-and-sort-it/1084780/19 "2021-02-06T14:10:49Z")

</div>

👍  
The `app variable name` already has a local copy of your DB so you should use this variable in the count loop instead of reusing the `cloud variable bestofviborg`

I would use this instead

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/f/0/f0d3c122a846787d5d8287d704ff07402e53b823.png)

---

<div class="post-metadata">

**Author:** ![funhall](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/funhall/32/92145_2.png) [@funhall](https://community.thunkable.com/u/funhall)\
**Post date:** [February 6, 2021, 2:16pm UTC](https://community.thunkable.com/t/how-to-get-a-very-long-list-from-firebase-and-sort-it/1084780/20 "2021-02-06T14:16:11Z")

</div>

so sorry but now I am a little confused.

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/1/d/1da563467208e93ffdbeecd66ed8bcb98e9a756e.png)  
What am I missing here??

---

<div class="post-metadata">

**Author:** ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)\
**Post date:** [February 6, 2021, 2:19pm UTC](https://community.thunkable.com/t/how-to-get-a-very-long-list-from-firebase-and-sort-it/1084780/21 "2021-02-06T14:19:08Z")

</div>

Place `logitude` on the top `get property` and place `address` in the lower `get property`

The order of the fields is in reverse.

[Next page](https://community.thunkable.com/t/how-to-get-a-very-long-list-from-firebase-and-sort-it/1084780.md?page=2)
