title: Vb.Net Sort 3x One Dimensional Arrays
body: <p>I have 3 one dimensional arrays.
  Each contains information that corresponds to the other 2 arrays.
  e.g Array 1 contains a customer first name
  Array 2 contains a customer last name
  Array 3 contains the customer phone number.</p>
  
  <p>This is not my actual example but is easiest to explain.
  How do I sort all three arrays so that they are sorted in order by say customer last name.
  If Mr Smith is sorted and has moved from position 10 to position 5 in the lastname array, I would expect his phone number and first name to also be in position 5 in the respective arrays.</p>
  
  <p>I am dealing with arrays with 10,000's of items so I would like to avoid looping (my current method) as this is incredibly slow.</p>
  
  <p>Hoping to use the array.sort methods.</p>
  
  <p>Can someone help me?</p>
  
  <p>Ok - So I have tried to use a new data Type but am still at a loss how I can instantly filter using this. Below is my sample code which has a couple of issues. If someone can resolve - it would love to learn how you did it.</p>
  
  <p>The purpose of the code is to return an array containing grouped issues.
  For simplicity I have assumed in the example that each constant found is an issue.
  If an issue is found, combine it with other issues found on that same worksheet.
  e.g The number 2 is found in both cells A1 and A2 on sheet 1. The array should return A1:A2.
  If the issues are found in A1 on sheet 1 and A2 in sheet 2, two seperate array entries would be returned.</p>
  
  <p><a href="https://www.dropbox.com/s/qnnma14vyli7do1/Filter%20Example.xlsm" rel="nofollow">Test File and Code Here</a></p>
  
  <pre><code>Public Type Issues
      ws_Sheet As Integer
      rng_Range As String
      s_Formula As String
      s_Combined As String
      d_ItemCount As Double
  End Type
  
  Sub IssuesFound()
  
  Dim MyIssues() As Issues
  Dim i_SheetCount As Integer
  Dim s_Formula As String
  Dim rng_Range As Range
  Dim d_IssueCounter As Double
  Dim s_SearchFor As String
  Dim a_TempArray() As Issues
  Dim d_InsertCounter As Double
  
  
  d_IssueCounter = -1
  
  ' Loop All Sheets Using A Counter Rather Than For Each
  For i_SheetCount = 1 To ActiveWorkbook.Sheets.Count
  
      ' Loop all Constants On Worksheet
      For Each rng_Range In Sheets(i_SheetCount).Cells.SpecialCells(xlCellTypeConstants, 23)
  
          If d_IssueCounter = -1 Then
              ' First Time and Issue Is Found, Start Recording In An Array
              d_IssueCounter = d_IssueCounter + 1
              ReDim MyIssues(0)
              MyIssues(0).ws_Sheet = i_SheetCount
              MyIssues(0).rng_Range = rng_Range.AddressLocal
              MyIssues(0).s_Formula = rng_Range.Value
              MyIssues(0).s_Combined = i_SheetCount &amp; "#" &amp; rng_Range.Value
              MyIssues(0).d_ItemCount = 0
  
          Else
              ' Going To Look For Issues Found On The Same Sheet with The Same Constant Value
              s_SearchFor = i_SheetCount &amp; "#" &amp; rng_Range.Value
  
              ' HELP HERE: Need To Ideally Return Whether The Above Search Term Exists In The Array
              ' Without looping, and I want to return the position in the array if the item is found
               a_TempArray = MyIssues 'Filter(MyIssues.s_Combined, s_SearchFor, True, vbTextCompare)
  
              If IsVarArrayEmpty(a_TempArray) = True Then
                  ' New Issue Found - Increase Counter By + 1
                  d_IssueCounter = d_IssueCounter + 1
  
                  ' Increase The Array By 1
                  ReDim Preserve MyIssues(d_IssueCounter)
  
                  ' Record The Information About The Constant Found. Sheet Number, Constant, Range, and also a combined string for searching and the array position
                  MyIssues(0).ws_Sheet = i_SheetCount
                  MyIssues(0).rng_Range = rng_Range.AddressLocal
                  MyIssues(0).s_Formula = rng_Range.Value
                  MyIssues(0).s_Combined = i_SheetCount &amp; "#" &amp; rng_Range.Value
                  MyIssues(0).d_ItemCount = 0
  
              Else
                  ' Get The Array Position Where Other Issues With The Same Worksheet and Constant are Stored
                  d_InsertCounter = a_TempArray.d_ItemCount
  
                  ' Add The New Found Constant To The Range Already Containing The Same Constants on This Worksheet
                  MyIssues(d_InsertCounter).rng_Range = Union(rng_Range, Range(MyIssues(d_InsertCounter).rng_Range)).AddressLocal
  
              End If
  
          End If
      Next
  
  Next
  
  End Sub
  
  Function IsVarArrayEmpty(ByRef anArray As Issues)
  
  Dim i As Integer
  
  On Error Resume Next
      i = UBound(anArray, 1)
      If Err.Number = 0 Then
          IsVarArrayEmpty = False
      Else
          IsVarArrayEmpty = True
      End If
  
  End Function
  </code></pre>
  
  <p><a href="https://www.dropbox.com/s/qnnma14vyli7do1/Filter%20Example.xlsm" rel="nofollow">Sample Test File and Code Here</a></p>