From: Sam Kong Date: 2006-09-20T03:55:15+09:00 Subject: What's the ruby way to sort string with cases in mind Hi, I'd like to sort an array of strings case-insensitively. However, if 2 strings are case-insensitively same, I want capital letters to come first. a = %w(a c b A C B) a.sort_by { |i| i.upcase } # => ["a", "A", "b", "B", "c", "C"] Actually, I want ["A", "a", "B", "b", "C", "c"] . I can get the result with the following trick. a.sort_by {|i| i.upcase + i} But I think there's a more rubyish way. How do you do that? Thanks in advance. Sam