← Back to challenges

Sorting Band Names without Articles

PythonHardarraysregexstrings

Instructions

Create a function that sorts the given array of band names discounting the articles "The", "A", "An" if the first word of the name categorically belongs to.

Examples

band_names_sort(["The New Yardbirds", "The Beatles", "The Square Roots", "On A Friday", "An Irony"])
➞ ["The Beatles", "An Irony", "The New Yardbirds", "On A Friday", "The Square Roots"]

band_names_sort(["The Platters", "A Yard of Yarn", "The Everly Brothers", "A Monster Effect", "The Sex Maggots"])
➞ ["The Everly Brothers", "A Monster Effect", "The Platters", "The Sex Maggots", "A Yard of Yarn"]

band_names_sort(["But Myth", "An Old Dog", "Def Leppard", "The Any Glitters", "The Dawn"])
➞ ["The Any Glitters", "But Myth", "The Dawn", "Def Leppard", "An Old Dog"]

Notes

You have to return the sorted full band names.

python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.