On Jan 16, 3:03    殮
> Hi All,
>
> Long time reader -- first time poster.   
> data that is sucked in from a file.   > it is my understanding that this data by default will be a string even
> if the contents of that string are a bunch of digits.    > case that a string is solely composed of digits, I want to convert
> them to a float for the purpose of using the <=> operator.  §
> go ahead and throw in my method and let you guys tear it a part.  
> goal of the function is to soft my array of arrays based on a
> particular element defined by a 'key'.      > to do this all together.
>
> def sort(*keys) options = {}
> regex = "^(\d)*$"
> newData = Array.new
> keys.reverse!
> keys.each do |key|
> newData = @data
> keyIndex = @header.index(key)
> newData.sort! do |entry1, entry2|
> if (!(entry1[keyIndex].match(regex).nil? && entry2
> [keyIndex].match(regex).nil?))
> print "I found only digits\n"
> entry1[keyIndex].to_f <=> entry2[keyIndex].to_f
> else
> #print "I found something other than digits\n"
> entry1[keyIndex] <=> entry2[keyIndex]
> end
> end
> end
> newTable = Table.new({
> header => @header,
> data => newData
>  > newTable
> end
>
> Thanks in advance for you feedback.       
> thick skin and am still learning.

Hi All,

I went ahead and changed my method to:

  def sort(*keys) options = {}
    regex = Regexp.new('^\d+$')
    newData = Array.new
    keys.reverse!
    keys.each do |key|
      newData = @data
      keyIndex = @header.index(key)
      newData.sort! do |entry1, entry2|
        if (entry1[keyIndex] =~ regex && entry2[keyIndex] =~ regex)
          #print "I found only digits\n"
          entry1[keyIndex].to_f <=> entry2[keyIndex].to_f
        else
          #print "I found something other than digits\n"
          entry1[keyIndex] <=> entry2[keyIndex]
        end
      end
    end
    newTable = Table.new({
                           :header => @header,
                           :data => newData
                         })
    newTable
  end

Now the question still remains if there is a better way to do this
sorting.