I am trying to sort the ListPart list. I tried listpart.sort(true) but it errors out. I checked the whole list to see if there were any anomalies but they are all numbers (2-4 digit)
B4X:
Sub FillArray(Search As Int)
If Search < 99 Then
partsList = su.LoadCSV(File.DirDocuments, "Database.txt", TAB)
Dim MyArray (partsList.size,24) As String
listpart.Initialize
lastx = partsList.Size -2
For i=0 To partsList.Size -2
Dummy = partsList.Get (i)
For j= 0 To 24
MyArray (i,j)= Dummy(j)
Next
listpart.Add(cs.Initialize.Font(fnt).Append(MyArray(i,Search)).PopAll)
Next
SearchIndex = Search
PickerPart.SetItems(0,listpart)
PickerPart.SetRowsHeight(40)
End If
End Sub
So the command to create the OrderedMap is below but I am not sure how to implement this into my for next loop since I am only looking at the adding a numeric value which I assume is the value but what would be the key?
The first column in the partsList ir MyArray is a unique identifier but then I tried the code below to add that and I see the warning "Types do not match"
B4X:
From website
Dim om As B4XOrderedMap = B4XCollections.CreateOrderedMap2(Array("a", "b", "c", "d"), Array(1, 2, 3, 4))
My Code
Dim om As B4XOrderedMap = B4XCollections.CreateOrderedMap2(MyArray(i,0),MyArray(i,search))
Dim om As B4XOrderedMap = B4XCollections.CreateOrderedMap
For i=0 To partsList.Size -2
Dummy = partsList.Get (i)
For j= 0 To 24
MyArray (i,j)= Dummy(j)
Next
om.Put((MyArray(i,Search), cs.Initialize.Font(fnt).Append(MyArray(i,Search)).PopAll)
Next
om.Keys.Sort(True)
For Each s As String In om.Keys
listpart.Add(om.Get(s))
Next