runtime
142 / 500
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.

Functionsort_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']

Loading your progress…

A name sort that crashes — Python practice · Runtime