I wonder if anyone can help me to change the cod so it will also sort
a empty table (nil)?
BR/Hamid


 # Verify the sort order of a table.
  # * first_row: The number if the first row in the table
  # * last_row: The number if the last row in the table
  # * column: The column number to verify order in.
  # * order: The order to check (asc, desc)
  def verifyTableSortOrder(first_row, last_row, column, order)

    current_row = first_row
    last_value = nil

    # Get first value and put into last_value
    while(current_row <= last_row && (!last_value ||
last_value=='NA'))
      last_value = self.getValueInTable(current_row, column)
      current_row += 1
    end

    if(last_value[/http:/]) # URL(images) should be sorted first
      last_value = ' ' # First char in ascii sort order
    elsif(is_time = self.parseTime(last_value))
      last_value = is_time
    elsif(numeric?(last_value))
      last_value = last_value.to_f
    else
      last_value = last_value.downcase
    end

    success = true
    while(current_row <= last_row)
      current_value = self.getValueInTable(current_row, column, 1)

      if(!current_value || current_value == 'NA')
        # "No comparison"
        current_row += 1
        next
      elsif(current_value[/http:/]) # URL(images) should be sorted
first
        # "URL comparison"
        current_value = ' ' # First char in ascii sort order
      elsif(is_time)
        # "Time comparison"
        current_value = self.parseTime(current_value)
      elsif(numeric?(current_value) && last_value.class==Float)
        # "Numeric comparison"
        current_value = current_value.to_f
      else
        # "String comparison"
        current_value = current_value.downcase()
        last_value = last_value.to_s
      end

      if(order[/asc/i])
        unless(current_value>=last_value)
          self.failure("Column #{column} was not sorted Ascending. #
{current_value} < #{last_value}")
          success = false
        end
      elsif(order[/desc/i])
        unless(current_value<=last_value)
          self.failure("Column #{column} was not sorted Descending. #
{current_value} > #{last_value}")
          success = false
        end
      end
      last_value = current_value
      current_row += 1
    end
    if(success)
      self.success("Column #{column} was sorted #{order}")
    end
  end
-- 
You received this message because you are subscribed to the Google Groups 
"Watir General" group.
To post to this group, send email to watir-general@googlegroups.com
Before posting, please read the following guidelines: 
http://wiki.openqa.org/display/WTR/Support
To unsubscribe from this group, send email to 
watir-general-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/watir-general

Reply via email to