Last active
December 24, 2015 01:09
-
-
Save ahimmelstoss/6721180 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'awesome_print' | |
songs = [ | |
"The Magnetic Fields - 69 Love Songs - Parades Go By", | |
"The Magnetic Fields - Get Lost - Smoke and Mirrors", | |
"Neutral Milk Hotel - In An Aeroplane Over the Sea - Holland 1945", | |
"The Magnetic Fields - Get Lost - You, Me, and the Moon", | |
"The Magnetic Fields - 69 Love Songs - The Book of Love", | |
"Neutral Milk Hotel - In An Aeroplane Over the Sea - The King of Carrot Flowers" | |
] | |
def sort_by_band(artist_name, songs_array) | |
artist_name_array = [] | |
songs_array.each do |song| | |
if song.split(" - ").first == artist_name | |
artist_name_array.push song | |
end | |
end | |
ap artist_name_array.sort! | |
end | |
sort_by_band("The Magnetic Fields", songs) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment