Results 1 to 3 of 3

Thread: Sorting Parallel Arrays

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2011
    Posts
    15

    Sorting Parallel Arrays

    In Visual Basic 2005 is it possible to parallel sort three or maybe four arrays? I have a function that is trying to accomplish this but it only parallel sorts the second array with the Array that it is being sorted with. Here is the code

    Code:
       Sub ParallelListBoxSort(ByVal byList As ListBox, ByVal otherLists() As ListBox)
            Dim ii As Integer = 0
            Dim a As Integer = otherLists.Length
            Dim lstArray() As String = listToArray(byList)
            While ii < a - 1
                Dim newArray() As String = listToArray(otherLists(ii))
                Array.Sort(lstArray, newArray)
                MessageBox.Show(otherLists(ii).Name)
                setArrayToListCollection(otherLists(ii), newArray)
                If ii = 0 Then
                    setArrayToListCollection(byList, lstArray)
                End If
                ii += 1
            End While
       End Sub
    'listToArray' is just a function that converts a list to an 1-Dimensional array and 'setArrayToListCollection' just puts the array back into the appropriated list. Thank you for any help or advice you have to offer.

  2. #2
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,415

    Re: Sorting Parallel Arrays

    try this:
    Attached Files Attached Files

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Sorting Parallel Arrays

    Quote Originally Posted by CrisIsRatedX View Post
    In Visual Basic 2005 is it possible to parallel sort three or maybe four arrays?
    Yes, but there really is no good reason to do so. You really should be defining a class with the appropriate properties so that, instead of having three or four arrays/collections, you have one array/collection of objects that have three or four properties. You could bind that one list to all your ListBoxes and then simply sort the list as desired and each ListBox will reflect that.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width