Hello thunkers.
Today im here for the following issue:
I will simplify things to focus only on result, so lets say ill generate 2 lists, as in image below.
After generating, because were generated in the same time, i will know exactly that the 3rd value in list1 will be “1,3” , and the same 3rd value in list2 will be “c”
But the issue occurs after il want list1 to be sorted.
If all values in list1 are different, all works just fine, using “first occur” in list1 to find correspondent value in list2. But if theres more than 1 value similar in list1, “first occurence” wont do the job.
Ill attach an image to understand my issue better.
Fortunatly, list1 and list2 are properties of the same object (as you see in block2)
So if i sort list1, list2 will have the same order based on list 1 ? this simplify things alot…
Thank you very much
But how do i retrieve “#” - index of list1`s value to apply in my example for list2 ? (that will be the same, as you said … Maybe ill need a new variable to store as a loop this ?
… ill test it as soon as ill get home…
Thank you again
Latwer, after testing. @muneer , i tested and it doesnt work. Maybe the lists as property of the same object are sorted togheter as i sort one list, but using a variable “contor” to keep index of list1 to retrieve value from list2 as the same index doesnt work. One of these 2 ideeas dont work … I guess that my “contor” is the issue, and need something else to retrieve index of list1`s current value
oh, got it now… need to rethink the whole variables for that. thank you.
the problem is that i do not know the lenght of lists, so i need to generate this new object dinamically, but this will do it
To make it clearer, I added a List Viewer and a button in the screen and following is the code in the click event of the button. Every time you click the list will be randomly shuffled but you can see from the list that they relation between the numbers and letters remain unchanged.
“shuffle” is the easy thing… but i need it to be sorted by value1 in your examples … and dunno how to… and im returning at the beginning of the problem…
Hello thunkers. @muneer , thank you again for your solution. Works like a charm for 1 digit values, when even if numbers are treated as text, 1 will be smaller as 5 in ascending order, and so on…
But if values are higher, app will say, for example, that 100 is smaler than 5 :)… because as text it will compare 1 to 5 first. (sorting as numbers wont help in your solution…)
Any other ideea to workaround this new issue ?
Thank you.
That is very easy, in the project I shared I included a sorting function. In it I’m comparing “value1”, so if you have it as number it will compare it the correct way or you can include the get property of value1 inside a math function to force it to change to number.
If this is not clear enough, I can change the project to reflect that later when I’m at my computer.
thank you @muneer for taking so much time in this issue…
already applied in my project your first ideea, using JSON
im not the type that only copy paste someone else`s ideea, so i need to understand 1st what you have done with this new approach, using those functions and so on… … so many variables there that cant see it initialized and so on
thank you again.
I’m taking the list as input to the function and take the first element of the list and assume it is the lowest number.
I then going into a while loop (as long as there are entries in the list)
I then go into another loop inside the first loop going through each entry in the list and compare it with my lowest entry.
If the entry in the list is lower than my “lowest entry” then I take the entry in the list making it my new “lowest entry”
At the end of the inner loop my “lowest entry” is removed from the list and added to the result list and start the outer loop again.
If with every iteration of the outer loop you are removing an entry from the list and adding it to the result list then by the end of the loop (when the original list has no more entries) you will have the result list ordered.