I am extracting elements from an array:
- member_results.each do |member| = member
It returns something like this:
["John", "Jason", "Andy", "Zee", "Sandy", "Randy", "Grisham"]
I need to sort the array alphabetically, get only the first five unique elements from the array. Can someone recommend me an efficient way to write an assistant for this?
EDIT: Therefore, based on the answer received by squiguy, this is what I did:
member_results.map(&:downcase).sort.uniq.take(5)
This solves most of my problem. But when I show these results, I need them back in the original format.
For example the result could be grisHam, aNdy etc.
source share