Is there a quicksort method in TableView?
if you are using dates you should try this is you are using numbers 1,2,3.. and you get 1,11,12,..2,20,... than you should format to 2 numbers
01,02,03,...11,12,...20,21... and the sorting will be correct
Sub Activity_Create(FirstTime As Boolean)
'create second tableview
Dim table2 As Table
table2.Initialize(Me, "Table1", 5 ,Gravity.CENTER,True)
table2.AddToActivity(Activity, 200%x, 0dip, 100%x, 50%y)'the x is set bigger than the activity wight because i dont want to see the table view, its just for sorting
table2.clearall
table2.SetHeader(Array As String("Col1", "Col2", "Col3", "Col4","Col5"))
end sub
Sub sorter
Table2.ClearAll
Table1.sortTable(4,True) 'first sort the table1 with all his items negative and positive
Dim lastpos As Int 'want to start from the last item
lastpos = (Table1.Size - 1)
For i = 0 To Table1.Size - 1
If Table1.GetValue(4,lastpos - i) >= 0 Then
table2.AddRow(Array As String(Table1.GetValue(0,i),Table1.GetValue(1,i),Table1.GetValue(2,i),Table1.GetValue(3,i),Table1.GetValue(4,i)))' add all positive numbers to table2
Table1.RemoveRow(lastpos - i)
End If
Next
'now we have all negative numbers in table1 and all positive in table2
Table1.sortTable(4,False)'sort dec
table2.sorttable(4,True)
For i = 0 To table2.Size - 1
Table1.AddRow(Array As String(table2.GetValue(0,i),table2.GetValue(1,i),table2.GetValue(2,i),table2.GetValue(3,i),table2.GetValue(4,i)))
Next
End Sub
B4X:Sub sorter End Sub
I dont want to sort when adding items. I want to sort when user clicks on header. I dont know where to place this sorter. Should this be in table class or main program?call it when you add items to table1 you would like to get them sorted when you add them right?
or you want them to be sorted only if you export them??
cal the sub when you like to sort the tableview, like you said when you click the header
is it working i have not test my code
table2.AddRow(Array As String(Table1.GetValue(0,i),Table1.GetValue(1,i),Table1.GetValue(2,i),Table1.GetValue(3,i),Table1.GetValue(4,i)))' add all positive numbers to table2
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?