class Alphabetize
Attributes
alphabet[RW]
set the alphabet as a string using this accessor Ex. x = Alphabetize.new x.alphabet = “abcĉdefgĝhĥijĵklmnoprsŝtuŭvz”
Public Instance Methods
alphabetize(arr)
click to toggle source
takes an array of strings as an argument and orders them alphabetically based on the alphabet set using the alphabet accessor
# File lib/alphabet_soup/alphabet_class.rb, line 14 def alphabetize(arr) arr.sort_by do |word| word.split("").collect do |letter| split_alphabet = alphabet.split("") if split_alphabet.include?(letter) split_alphabet.index(letter) else split_alphabet.count end end end end