I am looking for some help comparing the order of 2 Python lists, list1 and list2, to detect when list2 is out of order.
- list1 is static and contains the strings
a,b,c,d,e,f,g,h,i,j. This is the "correct" order. - list2 contains the same strings, but the order and the number of strings may change. (e.g.
a,b,f,d,e,g,c,h,i,jora,b,c,d,e)
I am looking for an efficient way to detect when list2 is our of order by comparing it against list1.
For example, if list2 is a,c,d,e,g,i should return true (as the strings are in order)
While, if list2 is a,d,b,c,e should return false (as string d appears out of order)
list1is always in alphabetical order, I'm wondering if you need to checklist2against it all. Would it work if you simplied checked iflist2is in alphabetical order of itself? - Darren Haynes