re: Daily Challenge #245 - Sort Santa's Reindeer VIEW POST



def sort_reindeer(reindeer)
  reindeer.sort_by { |r| r.split.last }

Hehe, Ruby can be quite concise at times. A better version would actually be

reindeer.sort_by { |r| r.split.reverse }

which would sort by last names then first names.


I think last time I saw @ben post a response, it was in Ruby and reactions were pretty much the same.

I think it was combining arrays into 1?

arr1 + arr2

That concatenates them, yes. You can also do union (arr1 | arr2) and intersection (arr1 & arr2) or multiply an array by an integer ([1] * 3 == [1, 1, 1]).

code of conduct - report abuse