Skip to content

Instantly share code, notes, and snippets.

@hachy
Created January 30, 2014 02:21
Show Gist options
  • Save hachy/8701453 to your computer and use it in GitHub Desktop.
Save hachy/8701453 to your computer and use it in GitHub Desktop.
ローマ字をあいうえお順にソート
aiueo = "aiueokgsztdnhbpmyrw"
alpha = "a-s"
nogizaka = %w(shiraishimai akimotomanatsu matsumurasayuri ikomarina hatanakaseira itounene itoumarika itoukarin itoujunna ikutaerika)
puts nogizaka.sort_by { |name| name.tr(aiueo, alpha) }
# => akimotomanatsu
# => ikutaerika
# => ikomarina
# => itoukarin
# => itoujunna
# => itounene
# => itoumarika
# => shiraishimai
# => hatanakaseira
# => matsumurasayuri
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment