tufanv Expert Licensed User Longtime User Apr 12, 2017 #1 Hello, I have a list in my app. Is there any way to change the sort of the list from the reverse , I mean if we have 4,7,5,8,1,2 in our list is it possible to make the list 2,1,8,5,7,4 Thanks
Hello, I have a list in my app. Is there any way to change the sort of the list from the reverse , I mean if we have 4,7,5,8,1,2 in our list is it possible to make the list 2,1,8,5,7,4 Thanks
tufanv Expert Licensed User Longtime User Apr 12, 2017 #2 I solved it with another list but maybe there is an easier way Upvote 0
stevel05 Expert Licensed User Longtime User Apr 12, 2017 #3 As the items are not actually sorted the simplest way is to use another list and add the items in reverse order. Upvote 0
As the items are not actually sorted the simplest way is to use another list and add the items in reverse order.
eps Expert Licensed User Longtime User Apr 12, 2017 #5 @udg has the best idea. It's a bit difficult to know how you're accessing your 'list' though.. Where it comes from and how it's populated as well.. Upvote 0
@udg has the best idea. It's a bit difficult to know how you're accessing your 'list' though.. Where it comes from and how it's populated as well..
udg Expert Licensed User Longtime User Apr 12, 2017 #6 @@udg has the best idea. Click to expand... You know it..I am lazy Upvote 0
eps Expert Licensed User Longtime User Apr 12, 2017 #7 Not at all! (I was going to suggest the same) Upvote 0
sadeq.hitex Member Licensed User Jul 2, 2022 #8 The easiest way to reverse a list : my list : B4X: Dim list1 As List = Array As Int(4,7,5,8,1,2) use 'reverse' code : B4X: Dim java As JavaObject java.InitializeStatic("java.util.Collections").RunMethod("reverse", Array(list1)) log to see the result : B4X: Log("list : " & list1) The final result will be : B4X: list : (ArrayList) [2, 1, 8, 5, 7, 4] ...Note... : You can use B4X: list1.Sort(True) but in this case , the items must all be numbers or strings! Last edited: Jul 2, 2022 Upvote 0
The easiest way to reverse a list : my list : B4X: Dim list1 As List = Array As Int(4,7,5,8,1,2) use 'reverse' code : B4X: Dim java As JavaObject java.InitializeStatic("java.util.Collections").RunMethod("reverse", Array(list1)) log to see the result : B4X: Log("list : " & list1) The final result will be : B4X: list : (ArrayList) [2, 1, 8, 5, 7, 4] ...Note... : You can use B4X: list1.Sort(True) but in this case , the items must all be numbers or strings!