-
Apr 7th, 2021, 09:19 PM
#1
Thread Starter
New Member
Add Sort Combined TextFiles
Hello everyone I have a program where I am combining three text files into one. When the text files are combined. I wanted to sort it by state alphabetically in the combined file. My code doesn't seem to sort by state in my text file when combined. Where am I going wrong?
Code:
Public Class newsenatefrm
Private Sub generatebtn_Click(sender As Object, e As EventArgs) Handles generatebtn.Click
Dim file1() As String = IO.File.ReadAllLines("Senate113.txt")
Dim file2() As String = IO.File.ReadAllLines("NewSen.txt")
Dim file3() As String = IO.File.ReadAllLines("RetiredSen.txt")
Dim combinedfiles As New List(Of String)
combinedfiles.addRange(file1)
combinedfiles.AddRange(file2)
combinedfiles.AddRange(file3)
Dim query = From line In combinedfiles
Let state = Split(","c)(1)
Let name = Split(","c)(0)
Let party = Split(","c)(2)
Order By state Ascending
Select name, state, party
IO.File.WriteAllLines("Senate114.txt", query)
End Sub
End Class
-
Apr 8th, 2021, 12:06 AM
#2
Re: Add Sort Combined TextFiles
you forgot to add 'Order By'
something like this
Code:
Dim query = From line In combinedfiles
Let state = Split(","c)(1)
Let name = Split(","c)(0)
Let party = Split(","c)(2)
Order By state Ascending
Select name, state, party Order By state Descending
to hunt a species to extinction is not logical !
since 2010 the number of Tigers are rising again in 2016 - 3900 were counted. with Baby Callas it's 3901, my wife and I had 2-3 months the privilege of raising a Baby Tiger.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|