beyondgrader.com Logo
DemoBrowseAboutTeamLogin

Sort Colors

[email protected] // 1.0

Write a function called sort_colors that takes a list of strings and returns a new list of those strings, sorted in rainbow order: first red, then orange, yellow, green, blue, and finally purple.

If an item in the list is not one of those six colors (case-sensitive), raise a ValueError. Note that the input may contain duplicate colors and you should preserve them. For example, given ['blue', 'red', 'blue'], you would return ['red', 'blue', 'blue'].