i want to sort files by what is actually in the files rather than just by their name. I have the following which sorts them by their name:
I have numbers in the files I want to sort them by and not by the name of the file. Can anyone give me any suggestions?Code:Private Sub SortFilesAzimuth() Dim flbs(FilesLB.Items.Count - 1) As FileListBoxItem FilesLB.Items.CopyTo(flbs, 0) Dim dt As New DataTable() dt.Columns.Add(New DataColumn("OrigIndex", System.Type.GetType("System.Int32"))) dt.Columns.Add(New DataColumn("FileIndex", System.Type.GetType("System.Int32"))) For i As Integer = 0 To flbs.Length - 1 Dim r As DataRow = dt.NewRow r("OrigIndex") = i r("FileIndex") = flbs(i).Index dt.Rows.Add(r) Next Dim dv As New DataView(dt) dv.Sort = "FileIndex ASC" For i As Integer = 0 To dv.Count - 1 Dim flb As FileListBoxItem = flbs(CType(dv(i)("OrigIndex"), Integer)) Me.FilesLB.Items.Remove(flb) Me.FilesLB.Items.Insert(i, flb) Next End Sub
Thanks




Reply With Quote