Z12869: Difference between revisions
protection for lists with elements of multiple types |
add a debug printout |
||
Line 14: | Line 14: | ||
"Z61K1": "python" |
"Z61K1": "python" |
||
}, |
}, |
||
"Z16K2": "def Z12741(Z12741K1, Z12741K2):\r\n if len(Z12741K1) != len(Z12741K2):\r\n return False\r\n\r\n # Define a custom sorting function. It will sort elements first by type, then by value\r\n def custom_sort(element):\r\n return (str(type(element)), element)\r\n\r\n try:\r\n return sorted(Z12741K1, key=custom_sort) == sorted(Z12741K2, key=custom_sort)\r\n except TypeError:\r\n # If there is a TypeError while sorting, it means there were non-comparable types in the list\r\n return False" |
"Z16K2": "def Z12741(Z12741K1, Z12741K2):\r\n if len(Z12741K1) != len(Z12741K2):\r\n return False\r\n\r\n # Define a custom sorting function. It will sort elements first by type, then by value\r\n def custom_sort(element):\r\n return (str(type(element)), element)\r\n\r\n try:\r\n \tWikifunctions.Debug(sorted(Z12741K1, key=custom_sort))\r\n \tWikifunctions.Debug(sorted(Z12741K2, key=custom_sort))\r\n return sorted(Z12741K1, key=custom_sort) == sorted(Z12741K2, key=custom_sort)\r\n except TypeError:\r\n # If there is a TypeError while sorting, it means there were non-comparable types in the list\r\n return False" |
||
} |
} |
||
}, |
}, |
Revision as of 05:33, 27 February 2024
This page displays in a limited way without JavaScript.