Forum Discussion
- AshokKumarSahooContributor
'####################################################################################################
'# Function Name : fn_ValidateArrayOrder
'# Description : This method will verfy an array is ascending or descending order
'# Input parameters : arrInput,strOrderType
'# arrInput : Array as input
'# strOrderType : ASCENDING or DESCENDING
'# Return Value : True or False
'####################################################################################################
Function fn_ValidateArrayOrder(arrInput,strOrderType)
On Error resume Next
Dim BlnFlag
BlnFlag = False
Select Case UCase(strOrdertype)
Case "ASCENDING"
For i = 0 to UBound(arrInput)-1
If StrComp(arrInput(i), arrInput(i+1), 1)=-1 Then
BlnFlag = True
End If
Next
Case "DESCENDING"
For i = 0 to UBound(arrInput)-1
If StrComp(arrInput(i), arrInput(i+1), 1)=1 Then
BlnFlag = True
End If
Next
End Select
fn_ValidateArrayOrder=BlnFlag
End FunctionPlease try to use this code ,it may be help you.
- baxatobCommunity Hero
Hi,
Using Python as a scripting language, you can make a simple check:
def is_sorted(arr): if arr == sorted(arr): return True else: return False
arr = ['d', 'c', 'a', 'e', 'b']
is_sorted(arr)
>> False
arr = ['a', 'b', 'c', 'd', 'e']
is_sorted(arr)
>> True- sanjSuper Contributor
Instead of checking to see if its sorted why dont you just sort it and you are done
A sorted function can be used to sort an array list
Related Content
- 4 years ago
- 2 years ago
- 19 days ago
- 4 years ago
Recent Discussions
- 24 hours ago