Bil Kleb <W.L.Kleb / LaRC.NASA.Gov> writes:

>I have an array of strings,

>a = ["d3", "d33", "d4", "r16", "r33", "d34", "r34"]

>which I'd like to sort by both the numerical suffix and by
>the alphabetic prefix, i.e., I'd like the result,

> ["d3", "d4", "d33", "d34", "r16", "r33", "r34"]

This is a case of multi-key sorting:

  a.sort{ |x,y| keys(x) <=> keys(y) }

Now all that is needed is to split your original strings into the component
keys used for comparison.  Something like:

def keys( str )
  ary = str.scan(/[a-z]+|\d+/)
  ary[1] = ary[1].to_i
  ary
end

Will probably suffice.

Regards,

Raja