CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Jun 2000
    Location
    Maryland
    Posts
    181

    Sort a multi_dimension array??

    Suppose I have a multidim array, say

    Name serialNum Mileage
    Benz 1111 9990
    Saab 1211 9990
    Benz 2111 7790
    Benz 1111 9990
    Fiat 1131 9990
    Benz 1111 1190
    Benz 1114 8890
    Saab 1151 2290

    Etc… you know what I mean.

    I want to programmatically sort this array by name,
    And mileage. What is the best way to go about it.
    Does anyone have a code to do this.

    Note, I dot want to use Excel's VBA code.

  2. #2
    Join Date
    Jan 2003
    Location
    7,107 Islands
    Posts
    2,487
    You can use the linear sorting here (bubble sort), then just concatenate the key fields in the condition..

    If arr(i,0) & arr(i,2) > arr(j,0) & arr(j,2) then
    '
    '
    '
    elseIf arr(i,0) & arr(i,2) < arr(j,0) & arr(j,2) then
    '
    '
    '
    else
    '
    '
    '
    endif
    Busy

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

Featured