Public Class frmJustices

  Private Sub btnReorganize_Click(ByVal sender As System.Object,
                                  ByVal e As System.EventArgs) Handles btnReorganize.Click
    'Take data from a text file. Sort and restructure the data, 
    'and write it to a file.
    Dim justices() As String = IO.File.ReadAllLines("Justices.txt")
    Dim query = From line In justices
                Let data = line.Split(","c)
                Let firstName = data(0)
                Let lastName = data(1)
                Let yrAppointed = CInt(data(4))
                Order By yrAppointed, firstName
                Let newLine = firstName & " " & lastName & "," & yrAppointed
                Select newLine
    IO.File.WriteAllLines("NewFile.txt", query)
  End Sub

End Class
