The best way to check if two lists have identical values

Steven D'Aprano steve at REMOVE-THIS-cybersource.com.au
Thu Feb 25 18:18:09 CET 2010


On Thu, 25 Feb 2010 14:30:12 +0100, mk wrote:

> In above example I assumed that the same values have to be repeated the
> same numbers of times in both lists and that order doesn't matter so
> long as the values are the same.

sorted(list1) == sorted(list2)

> I was wondering if there's a better / shorter / faster way to do this --
> not necessarily in the same variant, e.g. variant where order of two
> lists matters would be interesting as well.

list1 == list2




-- 
Steven



More information about the Python-list mailing list