I am trying to determine if a list is sorted the same way as another list containing the same elements. For example:
a = ['a', 'b', 'c']
b = ['b', 'c', 'a']
if a != b:
You could simply compare sorted versions of the lists:
if a == b: print 'Same elements, same order' elif sorted(a) == sorted(b): print 'Same lists, different order' else: print 'Completely differeent'
There are of course more efficient ways to do this (e.g. you could check the lengths of the lists first...), but this is very readable.