How can I order a list of letters (“a”,“b”,“c”,…,“z”,“aa”,“ab”)? String#succ and don't seem to play well together in this case?

There was a solution in answers at link you've posted - you have to write own in way to sort_by{|i|i. Length,i} irb> %w{a be c z aa ab zz aaa}.shuffle. Sort_by { |i| i.

Length,i } => "a", "b", "c", "z", "aa", "ab", "zz", "aaa".

Awesome, thanks Nakilon I'm not sure how I missed that from the other thread. I'm going to give this a shot now. – Carter Jan 4 at 23:40 Thanks again, sort_by{|i|i.

Length,i} was indeed the trick that I needed! – Carter Jan 5 at 1:00 2 @Carter, yeah, this trick I've learned at SO. SO is a great teacher... sometimes... – Nakilon Jan 5 at 4:29.

You can override the method for your Item model to compare first by ID length, then by alphanumeric. Something like this: class Item Length other. Letter_id.

Length return len_comp if len_comp! = 0 self. Letter_id other.

Letter_id end end That way you first compare for shorter ID length (i.e. , "z" before "aa"), then lexicographically.

This sort of issue is exactly why some people discourage the use of String#succ. It clashes with Range, Object#to_a, and others. Anyway, you probably know this, but things like this might help... >> t => "x", "y", "z", "aa", "ab", "ac", "ad", "ae", "af", "ag" >> t.shuffle.

Sort_by { |e| "%3s" % e } => "x", "y", "z", "aa", "ab", "ac", "ad", "ae", "af", "ag" You could even renormalize this way and dispense with sort_by.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions