'##############################################################
'#################### String Sort #############################
'##############################################################
'*************************************************************
' Function Name : CheckStringSortAscending
' Parameter : An Array contains list of strings
' Description : This function checks the given list of
' strings are in ascending order
'*************************************************************
Function CheckStringSortAscending(strArray)
Dim aIndex
CheckStringSortAscending=True
For aIndex=0 To UBound(strArray)-1
If StrComp(lCase(strArray(aIndex)),LCase(strArray(aIndex+1)))>0 Then
CheckStringSortAscending=False
Exit Function
End If
Next
End Function
'*************************************************************
'#############################################################
'*************************************************************
' Function Name : CheckStringSortDescending
' Parameter : An Array contains list of strings
' Description : This function checks the given list of
' strings are in descending order
'*************************************************************
Function CheckStringSortDescending(strArray)
Dim aIndex
CheckStringSortDescending=True
For aIndex=0 To UBound(strArray)-1
If StrComp(lcase(strArray(aIndex)),lcase(strArray(aIndex+1)))<0 Then
CheckStringSortDescending=False
Exit Function
End If
Next
End Function
'*************************************************************
'############################################################## '#################### Date Sort ############################### '############################################################## '************************************************************* ' Function Name : CheckDateSortAscending ' Parameter : An Array contains list of Date Values ' Description : This function checks the given list of ' Date values are in ascending order '************************************************************* Function CheckDateSortAscending(dtArray) Dim aIndex CheckDateSortAscending=True For aIndex=0 To UBound(dtArray)-1 If DateDiff("d",dtArray(aIndex),dtArray(aIndex+1))<0 Then CheckDateSortAscending=False Exit Function End If Next End Function '************************************************************* '############################################################# '************************************************************* ' Function Name : CheckDateSortDescending ' Parameter : An Array contains list of Date Values ' Description : This function checks the given list of ' Date values are in Descending order '************************************************************* Function CheckDateSortDescending(dtArray) Dim aIndex CheckDateSortDescending=True For aIndex=0 To UBound(dtArray)-1 If DateDiff("d",dtArray(aIndex),dtArray(aIndex+1))>0 Then CheckDateSortDescending=False Exit Function End If Next End Function '*************************************************************
'############################################################## '#################### Numeric Sort ############################ '############################################################## '************************************************************* ' Function Name : CheckNumericSortAscending ' Parameter : An Array contains list of numbers ' Description : This function checks the given list of ' numbers are in Ascending order '************************************************************* Function CheckNumericSortAscending(numArray) Dim aIndex CheckNumericSortAscending=True For aIndex=0 To UBound(numArray)-1 If numArray(aIndex)>numArray(aIndex+1) Then CheckNumericSortAscending=False Exit Function End If Next End Function '************************************************************* '############################################################# '************************************************************* ' Function Name : CheckNumericSortDescending ' Parameter : An Array contains list of numbers ' Description : This function checks the given list of ' numbers are in Descending order '************************************************************* Function CheckNumericSortDescending(numArray) Dim aIndex CheckNumericSortDescending=True For aIndex=0 To UBound(numArray)-1 If numArray(aIndex)<numArray(aIndex+1) Then CheckNumericSortDescending=False Exit Function End If Next End Function '************************************************************* '#############################################################
i am very excited after seen this blog. it is very useful to beginners
ReplyDeleteHow do we verify sorting order if the contains combination of alphanumerics
ReplyDeleteeg: SC-150, SC-1
I need alpha numeric sort ascending and decending
ReplyDeleteI think string sorting is not right. U can not just convert the string to lower case and compare.because b and B has different ascii values.
ReplyDeleteI am skipping case sensitivity in this sorting. Most of the times it is not required.
Delete