# File lib/rubyrep/table_scan_helper.rb, line 16
    def rank_rows(left_row, right_row)
      raise "At least one of left_row and right_row must not be nil!" unless left_row or right_row
      return -1 unless right_row
      return 1 unless left_row 
      rank = 0
      primary_key_names.any? do |key|
        if left_row[key].kind_of?(String)
          # When databases order strings, then 'a' < 'A' while for Ruby 'A' < 'a'
          # ==> Use a combination of case sensitive and case insensitive comparing to
          #     reproduce the database behaviour.
          rank = left_row[key].casecmp(right_row[key]) # deal with 'a' to 'B' comparisons
          rank = -(left_row[key] <=> right_row[key]) if rank == 0 # deal with 'a' to 'A' comparisons
        else
          rank = left_row[key] <=> right_row[key]
        end
        rank != 0
      end
      rank
    end