question 142 Advanced Functions & Recursion · easy
A name sort that crashes
sort_names should list customer names A–Z without caring about capital letters, keeping each name exactly as it was typed. Instead it stops with TypeError: '<' not supported between instances of 'builtin_function_or_method' and 'builtin_function_or_method'. Find the bug and fix it.
Function
sort_names(names)namesa list of texts
Returnsa new list of the same names, A–Z ignoring capitals; names that differ only in capitals keep their input order
Keepthe original spelling of every name
Examples
callsort_names(['nora', 'Theo', 'grace', 'Jamal'])returns['grace', 'Jamal', 'nora', 'Theo']
callsort_names(['Zoe', 'adam'])returns['adam', 'Zoe']
callsort_names(['Ana', 'Ben'])returns['Ana', 'Ben']