I have an array arrX of Typed data items
I was looking to be lazy and use build in List sorting capabilities to sort my array
So I added the array elements to the list
This looks good I verified I have list of typed data with a "Brand" element
So far so good, that works
Now I want to sort this list
I get an error on that last line :
Any ideas ?
I have alternatives, I can write a sorting routine for the array,
but I'm learning B4A and it would be good to know what the problem is.
Thanks,
- Jeff ( B4AinNY )
B4X:
Public Const g_NumBrands As Int = 101
Type BrandData( _
Distributor As String, _
Brand As String, _
ItemTypeExists(18) As Boolean)
Public arrX(100) As BrandData
I was looking to be lazy and use build in List sorting capabilities to sort my array
So I added the array elements to the list
B4X:
Dim L As List
L.Initialize
L.addall ( ArrX )
This looks good I verified I have list of typed data with a "Brand" element
B4X:
Log ("GOT HERE")
Dim OneRecord As BrandData
OneRecord = L.Get(1)
Log ("Brand = " & x.Brand )
So far so good, that works
Now I want to sort this list
B4X:
' * Sort the List with List.Sort(True)
L.SortType("Brand", True)
I get an error on that last line :
B4X:
java.lang.RuntimeException: java.lang.NullPointerException: Attempt to invoke interface method 'int java.lang.Comparable.compareTo(java.lang.Object)' on a null object reference
at anywheresoftware.b4a.objects.collections.List$2.compare(List.java:208)
at java.util.TimSort.binarySort(TimSort.java:261)
at java.util.TimSort.sort(TimSort.java:204)
at java.util.TimSort.sort(TimSort.java:169)
at java.util.Arrays.sort(Arrays.java:2010)
Any ideas ?
I have alternatives, I can write a sorting routine for the array,
but I'm learning B4A and it would be good to know what the problem is.
Thanks,
- Jeff ( B4AinNY )