以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  请问数组集合排序  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=90205)

--  作者:hbhb
--  发布时间:2016/9/7 17:23:00
--  请问数组集合排序
大师:请问数组的集合如何根据数组的第一个排序?
--  作者:有点蓝
--  发布时间:2016/9/7 17:48:00
--  
利用临时表排序

Dim lst As new List(of String())
lst.Add(new String(){"1","2","3"})
lst.Add(new String(){"a","a","a"})
lst.Add(new String(){"8","8","8"})
lst.Add(new String(){"6","6","3"})

Dim dtb As New DataTableBuilder("A")
dtb.AddDef("A", Gettype(String), 32)
dtb.AddDef("B", Gettype(String), 32)
dtb.AddDef("C", Gettype(String), 32)
Dim t As DataTable = dtb.Build(True)
Dim dr As DataRow
For Each sarr As String() In lst
    dr = t.AddNew
    For i As Integer = 0 To sarr.Length - 1
        dr(t.DataCols(i).Name) = sarr(i)
    Next
Next
lst.Clear
Dim drs As List(Of DataRow) = t.Select("","A")
Dim lls As new List(of String)
For Each r As DataRow In drs
    lls.Clear
    For i As Integer = 0 To t.DataCols.Count - 1
        lls.Add(r(t.DataCols(i)))
    Next
    lst.Add(lls.ToArray)
Next

For Each sarr As String() In lst
    Output.Show(sarr(0) & "-" & sarr(1) & "-" & sarr(2))
Next

--  作者:hbhb
--  发布时间:2016/9/7 18:04:00
--  
谢谢!佩服!临时表还可以这么用!