From: WATANABE Hirofumi Date: 2006-09-20T17:50:46+09:00 Subject: Re: What's the ruby way to sort string with cases in mind Hi, "Rimantas Liubertas" writes: > > > And implementing your own > > sort routine is not going to be anywhere near as clean as what you've > > got. > > My best try so far is like that: > > a.sort{ |i,j| (i.upcase == j.upcase)? (i<=>j):(i.upcase<=>j.upcase) } > > Not elegant, but not too ugly (or is it?). I've got a feeling there > must be a way to simplify this. a.sort{ |i,j| [i.upcase, i] <=> [j.upcase, j] } a.sort_by{ |i| [i.upcase, i] } -- eban