I would like to do a process that filters me between the most recent tags to the oldest, I know that I have to edit something in the database for the filtering to work.
So far I can’t think of anything to be able to carry out the respective filter.
Does anyone know how I can filter the list from newest to oldest by fetching all labels?
exactly, I need to organize the data, I thought with the date and time.
But I don’t know how I could filter the data by telling the algorithm that identifies me which date is more recent than another.
to make the data run out and so the filtering can be completed, I have the theory but I don’t know how to implement it.
Process that allows me to organize the numbers from smallest to largest.
The result is: 1,2,3,4,5.
When it comes to putting it in a for each loop, it prints it from highest to lowest.
Now you have to adapt the database so that everything works:
NOTE: I added a letter to the labels, because for some reason when we call a list of labels it won’t show us something (I tried this before the phoenix version, I don’t know if they already fixed it hahaha).
Ready, problem solved.
Thanks to everyone who commented as they gave me some ideas.
The procedure I use in this case is not entirely correct when I say that it organizes from smallest to largest, because even though the results shown and the tests support that if it is correct, when trying to use disordered and incomplete lists like this: 4 , 7,100,1,57. He is not able to organize it; therefore, for this procedure to work, you must adhere to the following rule:
list length = maximum number in list
Example:
Correct way:
list length = 3;
then the list must be = (2,1,3).
Wrong way:
list length = 3;
so the list must be = (5,23,300).
Improvements:
When you add an item to the final list, it removes that item that no longer needs to be used again.
Use of break to break the second cycle, as long as the desired number is found. (so the second cycle will not have to continue running and at the same time spend resources and execution time) I say all this in the case of having to organize large lists such as 10,000 numbers etc.
If you are not using firebase authentication then you can use . json + dictionary method, there by you can get the firbase tag order list then by using reverse order or by using for each number from (length of the list ) to (1) by (-1) you can get the output as you like.
For ref (this method i learnt from (taught by) @dora_paz only)