List.
SortType (FieldName As String, Ascending As Boolean)
Sorts a list with items of user defined type. The list is sorted based on the specified field.
FieldName - The case-sensitive field name that will be used for sorting. Field must contain numbers or strings.
Ascending - Whether to sort ascending or descending.
Example:
Sub Process_Globals
Type Person(Name As String, Age As Int)
End Sub
Sub Activity_Create(FirstTime As Boolean)
Dim Persons As List
Persons.Initialize
For i = 1 To 50
Dim p As Person
p.Name = "Person" & i
p.Age = Rnd(0, 121)
Persons.Add(p)
Next
Persons.SortType("Age", True) 'Sort the list based on the Age field.
For i = 0 To Persons.Size - 1
Dim p As Person
p = Persons.Get(i)
Log(p)
Next
End Sub
B4J Question list sorttype - tufanv    
Nov 21, 2017Hello,
I have a list like this when i log the list:
log:(ArrayList)
As I can see there is a VOLUME24HOUR in the fields but when i use
Exchanges.SortType("VOLUME24HOUR",False)
it says...
link: .Sorttype does not work with Maps or List (inside the List). In ONLY works with custom types...
link: What is the type of each element in this list? It looks like a Map.
what is the output of the log...
B4A Question List.SortType() with Localization - Erel (first post)    
Feb 5, 2018   
(2 reactions)It is not possible. If all the relevant field values are unique then you can add them to a list and a map where they the key is the field value and the value is the custom type.
Sort the list and then get the types from the map....
link: , Array(l1, collator))
End Sub
How can I use this code with List.SortType() ?...
B4A Question [solved] using list.sortType with a class instead of a type - Dave O (first post)    
Nov 30, 2017   
(1 reaction)Hey @stevel05 , that did the trick, thanks!
FYI, I did find out that if you use sortType, it works fine with numbers. However, if you use sortTypeCaseInsensitive, it treats numbers as strings, so...
link: The field variable must be a Public Global not accessed by a getter (getField)....
link: Try prefixing the field name with an underscore and making the name lower case. So if your field is...
link: by one of the class fields. If this was a type (not a class), I could just use the list's sortType...
B4A Question List.SortType converted to Java ? - vdudukov (first post)    
Oct 30, 2017   
(1 reaction)Dear Erel,
Yes of course, i know that.
I am working with B4A since 2013, and it is my no.1 programm...
link: This forum is for questions related to development with B4A, not Java....
link: If you check the source-folder in your project, you may see the related equivalent code in java
Tha...
link: If you check the source-folder in your project, you may see the related equivalent code in java...
B4A Question Use a sorted list with SortType ("filename", False) - Erel (first post)    
Apr 12, 2016This by itself is not an error. Does the program crash? Is there any error in the logs?...
link: I'm using Type List, to sort a list, then the list orderly way to a method that takes as input...
Other B4i v1.21 is released - Erel    
Nov 23, 2014   
(15 reactions)B4i v1.21 is now available for download.
You can download it with the same links as v1.00. A mail will be sent with the links.
This version adds support for designer script and auto scale: http://www.basic4ppc.com/android/forum/threads/designer-script-autoscale-tutorial.47184/
These features make it much simpler to implement flexible layouts.
Other improvements:
List.SortType / SortTypeCaseInsensitive - Sorts a list made of user defined types.
NativeObject.RunMethodWithBlocks, AsBoolean...
B4J Tutorial Parsing huge text files - Erel    
Nov 24, 2013   
(5 reactions).Match, count + 1)
In order to sort the data we will add the data to a list and call List.SortType:
Dim list1 As List
list1.Initialize
For i = 0 To ips.Size - 1
Dim ic As IpAndCount
ic.Initialize
ic.ip = ips.GetKeyAt(i)
ic.count = ips.GetValueAt(i)
list1.Add(ic)
Next
list1.SortType....count = ips.GetValueAt(i)
list1.Add(ic)
Next
list1.SortType("count", False)
ic... = raf.ReadObject(0)
End If
raf.Close
Dim list1 As List
list1.Initialize
For i = 0...
Other B4i v7.80 has been released - Erel    
Oct 27, 2021   
(27 reactions)I'm happy to release a new version of B4i.
Improvements:
Support for Xcode 13.
Long hex literal numbers: 0xff00ff00ff00
New methods: Bit.OrLong / AndLong / XorLong / ShiftLeftLong / ShiftRightLong / NotLong / UnsignedShiftRightLong / ParseLong
List.SortType - stable sort. This means that equal items retain their order. It allows sorting by multiple fields.
Fix issue with Unicode sorting and string comparison (https://www.b4x.com/android/forum/threads/b4x-trie-based-search-dialog.134220...
Other B4i v7.80 BETA has been released - Erel    
Oct 18, 2021   
(21 reactions)I'm happy to release a new BETA version of B4i.
Improvements:
Support for Xcode 13.
Long hex literal numbers: 0xff00ff00ff00
New methods: Bit.OrLong / AndLong / XorLong / ShiftLeftLong / ShiftRightLong / NotLong / UnsignedShiftRightLong / ParseLong
List.SortType - stable sort. This means that equal items retain their order. It allows sorting by multiple fields.
Fix issue with Unicode sorting and string comparison (https://www.b4x.com/android/forum/threads/b4x-trie-based-search-dialog...
B4A Question Sorting of distances in map values - Erel (first post)    
Jan 19, 2023   
(1 reaction)Don't use a map. Create a custom type with the two fields. Add the items to a list and sort it with List.SortType....
link: it with List.SortType.
Going to give it a shot. Thanks...
Page: 1  
2  
3  
4  
5  
6  
7