In the app I'm making now, I have to read in a CSV-file (originating from Excel) into a List called Table. This works well by using LoadCSV2 from the StringUtils library :
Then I load the headers into two spinners for later use :
In the rest of the app I can work with the data in the List (Table) by getting a row (i) of data with :
and referencing to the individual columns with sColumn(x), where x is a reference to the column I need.
At the moment the list (Table) contains about 190 rows of about 46 columns.
From this Table some listviews are filled and shown on screen one at a time, selected by the user. From these listviews the user chooses an item. This opens a panel with details derived from Table.
So far everything works OK and I'm happy with the app as is.
But....
I would like to be able to sort the list on any of the columns, but I don't know how. Of course I tried reading the forums, User Guide and Beginner's Guide but never came far. Table.Sort(true) does not work but gives a java error :
LastException java.lang.ClassCastExeption:java.lang.String[] cannot be cast to java.lang.Comparable.
:sign0163:
B4X:
Table = su.LoadCSV2(File.DirRootExternal, PathAndFilenameDAT, ",", lstHeader)
Then I load the headers into two spinners for later use :
B4X:
For i = 0 To lstHeader.Size-2 'Last column in CSV-file is empty, so don't use
spnFirstLine.Add(lstHeader.Get(i))
spnSecondLine.Add(lstHeader.Get(i))
Next
spnFirstLine.SelectedIndex = Header1
spnSecondLine.SelectedIndex = Header2
B4X:
sColumn = Table.Get(i)
At the moment the list (Table) contains about 190 rows of about 46 columns.
From this Table some listviews are filled and shown on screen one at a time, selected by the user. From these listviews the user chooses an item. This opens a panel with details derived from Table.
So far everything works OK and I'm happy with the app as is.
But....
I would like to be able to sort the list on any of the columns, but I don't know how. Of course I tried reading the forums, User Guide and Beginner's Guide but never came far. Table.Sort(true) does not work but gives a java error :
LastException java.lang.ClassCastExeption:java.lang.String[] cannot be cast to java.lang.Comparable.
:sign0163: