Road to Great Code, Challenge #2 — Sort Playlist
Explore a new coding challenge, circa 2001 — sorting an iPod playlist!
Join the DZone community and get the full member experience.Join For Free
Last week, in the Road to Great Code, we implemented a playlist for shuffling a playlist. This week, we are still stuck in 2001 and the iPod release date is approaching rather quickly. However, no one — until now — noticed that songs on the device are not sorted alphabetically. You are tasked with this last-minute task, and you best get it right. You don’t want to get on Steve’s bad side. He promised to personally test this feature himself, so the pressure is on.
Here’s the starting point of the program that you must complete. Naturally, I’ve populated the playlist with all of the festive songs I could think of because you can’t really get enough of them… or can you?
mySort method so that it reorders the elements in the list in alphabetical order.
This is my solution. Did you come up with something better? Make sure to put your answer in the comments section. My solution is only one line, but do you think it’s maintainable? Let me know.
Opinions expressed by DZone contributors are their own.