这就是我如何处理 Ruby 哈希中的值以获得字母数字小写排序输出(极端示例):
myhash = {
"x" => "zebra",
"one" => "1",
"alpeh" => "alpha",
"lower" => "january",
"1" => "January",
"2" => "February",
"answer" => "42"
}
m = myhash.values
puts m.map{|i| i.downcase}.sort
输出:
1
42
alpha
february
january
january
zebra
这很好用,我没有问题,但想知道我是否缺少更简单/更有效的方法?