I've got:
@fruit = ["Apples, Oranges, Bananas", "Apples", "Bananas, Pears", "Bananas, Apples, Pears", "Pears"]
I want to do two different things with this, first turn it into a pure array with only one instance of each:
["Apples", "Oranges", "Bananas", "Pears"]
Secondly I want to be able to determine how many of a given instance there are in the array:
@fruit.count("Apples") = 3
Thirdly, is it possible to order the array by the number of instances:
@fruit.sort = ["Apples", "Apples", "Apples", "Bananas", "Bananas", "Bananas", "Pears", "Pears", "Pears", "Oranges"]
What array/string functions would I have to use to do this?