How to check if a list of string is ascending or descending?

hello , Here is the scenario I have two list of strings one list is either in ascending or descending order compared to other now I want to confirm if the list is in ascending or descending and have to write it in excel based on the result @Anil_G @Shiva_Nikhil @ppr

can you share sample data?

other wise take out 2 elements and check it for detecting the Ordering type

list1 = ( “Testing 32”, “Testing 1” , “Testing 2” , "abababa " )
list2 = ("abababa " , “Testing 1” , “Testing 2” , “Testing 32”)

this just a sample data

@GopiKrishnan_Srinivasan

check like this

list1.OrderBy(function(x) x).ToList.Equals(List1) - this gives truw if in ascending else will give false

similarly can you for list2

cheers

not achieving the desired result

then tell more about the difference of the result and the expected result

want to check

  • first list
  • second list
  • both list

maybe better to be more strict and clear

Hi @GopiKrishnan_Srinivasan

You can use If Condition here

(list1(0) = list2(0)) AndAlso (list1(list1.Count - 1) = list2(list2.Count - 1))

Hope this helps

@GopiKrishnan_Srinivasan

Can you please tell what is not expected

cheers

@GopiKrishnan_Srinivasan

Try this once

list_sorted=list_values1.OrderBy(Function(x) x).ToList

then use assign activity

booloutput=List_sorted.SequenceEqual(list_values1)

repeat the same for list2

image

image