title: .net - Sorting a Data Table
body: <p>How to sort datatable using VB.NET? I've already read this thread but I having the same output. 
  <a href="https://stackoverflow.com/questions/12472913/sorting-a-data-table">Sorting a Data Table</a>
  <a href="https://stackoverflow.com/questions/19505979/how-do-i-sort-a-datatable">How do I sort a datatable</a></p>
  
  <p>Also, I've tried the sample in Microsoft but still it's not sorting.</p>
  
  <pre><code>        Dim locationTable As New DataTable("Location")
      ' Add two columns
      locationTable.Columns.Add("State")
      locationTable.Columns.Add("ZipCode")
  
      ' Add data 
      locationTable.Rows.Add("Washington", "1")
      locationTable.Rows.Add("California", "2")
      locationTable.Rows.Add("Hawaii", "3")
      locationTable.Rows.Add("Hawaii", "4")
      locationTable.Rows.Add("Hawaii", "5")
      locationTable.Rows.Add("Hawaii", "6")
      locationTable.Rows.Add("Hawaii", "7")
      locationTable.Rows.Add("Hawaii", "8")
      locationTable.Rows.Add("Hawaii", "9")
      locationTable.Rows.Add("Hawaii", "10")
      locationTable.AcceptChanges()
  
      Console.WriteLine("Rows in original order" &amp; vbLf &amp; " State " &amp; vbTab &amp; vbTab &amp; " ZipCode")
      For Each row As DataRow In locationTable.Rows
          Console.WriteLine(" {0} " &amp; vbTab &amp; " {1}", row("State"), row("ZipCode"))
      Next
  
      ' Create DataView 
      Dim view As New DataView(locationTable)
  
      ' Sort by State and ZipCode column in descending order
      view.Sort = "ZipCode ASC"
  
      Console.WriteLine(vbLf &amp; "Rows in sorted order" &amp; vbLf &amp; " State " &amp; vbTab &amp; vbTab &amp; " ZipCode")
      For Each row As DataRowView In view
          Console.WriteLine(" {0} " &amp; vbTab &amp; " {1}", row("State"), row("ZipCode"))
      Next
  </code></pre>
  
  <p>The output is 
  Rows in sorted order</p>
  
  <p>State       ZipCode</p>
  
  <p>Washington      1</p>
  
  <p>Hawaii      10</p>
  
  <p>California      2</p>
  
  <p>Hawaii      3</p>
  
  <p>Hawaii      4</p>
  
  <p>Hawaii      5</p>
  
  <p>Hawaii      6</p>
  
  <p>Hawaii      7</p>
  
  <p>Hawaii      8</p>
  
  <p>Hawaii      9</p>
  
  <p>It should be 1 ~ 10 right? :(</p>