Sorting a two dimensional array in vb.net?
-
Can't seem to get it working, any ideas? Module Module1 Dim Array(3, 1) As String Sub InsertionSort(ByRef Array(ArraySize, 1) As String) Dim CurrentValue As Integer For CurrentValue = 0 To Array.Length - 1 Dim Pointer As Integer, Value As String = Array(0, CurrentValue) For Pointer = CurrentValue - 1 To 0 Step -1 If Array(0, Pointer) <= Value Then Exit For Array(0, Pointer + 1) = Array(0, Pointer) Next Array(0, Pointer + 1) = Value Next End Sub Sub Main() Array(0, 1) = "c" Array(1, 1) = "a" Array(2, 1) = "t" Array(3, 1) = "s" Dim ArraySize As Integer = Array.GetUpperBound(0) Dim CurrentValue As Integer InsertionSort(Array(ArraySize, 1)) For CurrentValue = 0 To Array.Length - 1 Console.WriteLine(Array(CurrentValue, 1)) Next For CurrentValue = 1 To Array.Length - 1 If Array(CurrentValue - 1, 1) > Array(CurrentValue, 1) Then Console.WriteLine("ERROR") End If Next End Module
-
Answer:
You should use linq it's much more powerful, you just convert your array to a list, then use linq. It can do the sorting as well.
VinylSea... at Yahoo! Answers Visit the source
Related Q & A:
- How to trigger a script in Google Spreadsheet with .NET?Best solution by jotform.com
- How do you create a Two-Dimensional ArrayList?Best solution by Stack Overflow
- How to save from DatagridView to Database VB.NET?Best solution by Stack Overflow
- What do people do on a two hour cruise?Best solution by Yahoo! Answers
- How does the transfer from a two-year college to a four-year university work?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.