Advertisement

10.25.2007 at 02:12PM PDT, ID: 22918910
[x]
Attachment Details

How can I do a case-insensitive sort a mulit-dimensional array

Asked by PatternNut in Visual Basic Programming

Tags: sort, array, case

Hi Experts,

I'm working in VB6 / VBA and I need to sort a multi-dimensional array of strings.   It all works really well except that the sort is case sensitive.  It puts all entries that start in caps first and all entries that start lowercase second.  Can any of you please tell me how to fix the SortIt function below to make it work right?

Thanks in advance,

PatternNut


Public Sub SortIt(ByRef A() As String, ByRef nA As Long, ByVal byCol As Long, lngTotalCol)
  'A = array
  'nA = ubound +1
  'bycol is the second variable to sort by eg (X,bycol)

  Dim i As Long
  Dim j As Long
  Dim tempST1 As String
  Dim tempST2 As String
  Dim lngCountCol As Long

  For i = 1 To (nA - 2)
    For j = (i + 1) To (nA - 1)
        If (A(j, byCol) < A(i, byCol)) Then
            For lngCountCol = 0 To lngTotalCol
                tempST1 = A(i, lngCountCol)
                A(i, lngCountCol) = A(j, lngCountCol)
                A(j, lngCountCol) = tempST1
            Next lngCountCol
        End If
    Next j
  Next i
 
End SubStart Free Trial
 
Loading Advertisement...
 
[+][-]10.25.2007 at 03:02PM PDT, ID: 20151867

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Visual Basic Programming
Tags: sort, array, case
Sign Up Now!
Solution Provided By: dsacker
Participating Experts: 2
Solution Grade: A
 
 
[+][-]10.25.2007 at 03:06PM PDT, ID: 20151884

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]10.25.2007 at 04:02PM PDT, ID: 20152192

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628