def custom_list_data_comparator(obj1, obj2):
if isinstance(obj1, dict) and isinstance(obj2, dict):<EOL><INDENT>obj1 = json.dumps(obj1, sort_keys=True)<EOL>obj2 = json.dumps(obj2, sort_keys=True)<EOL><DEDENT>try:<EOL><INDENT>return (obj1 > obj2) - (obj1 < obj2)<EOL><DEDENT>except TypeError:<EOL><INDENT>s1, s2 = type(obj1).__name__, type(obj2).__name__<EOL>return (s1 > s2) - (s1 < s2)<EOL><DEDENT>
Comparator function used to sort lists with complex data types in them. This is meant to be used only within the
context of sorting lists for use with unit tests.

Given any two objects, this function will return the "difference" between the two objects. This difference obviously
does not make sense for complex data types like dictionaries & list. This function implements a custom logic that
is partially borrowed from Python2's implementation of such a comparison:

* Both objects are dict: Convert them JSON strings and compare
* Both objects are comparable data types (ie. ones that have > and < operators): Compare them directly
* Objects are non-comparable (ie. one is a dict other is a list): Compare the names of the data types.
  ie. dict < list because of alphabetical order. This is Python2's behavior.