<commit_before>def ensure_key_sorting(h)
  sorted = h.keys.sort
  return h if sorted == h.keys
  sorted.reduce({}) { |memo, k| memo[k] = h[k]; memo }
end

module Chain
  class BatchResponse
    def initialize(successes: {}, errors: {}, response: nil)
      @successes = ensure_key_sorting(successes)
      @errors = ensure_key_sorting(errors)
      @response = response
    end

    def size
      successes.size + errors.size
    end

    attr_reader :successes, :errors, :response
  end
end
<commit_msg>sdk/ruby: remove method from global namespace<commit_after>module Chain
  class BatchResponse
    def initialize(successes: {}, errors: {}, response: nil)
      @successes = ensure_key_sorting(successes)
      @errors = ensure_key_sorting(errors)
      @response = response
    end

    def size
      successes.size + errors.size
    end

    attr_reader :successes, :errors, :response
  end

  private

  def ensure_key_sorting(h)
    sorted = h.keys.sort
    return h if sorted == h.keys
    sorted.reduce({}) { |memo, k| memo[k] = h[k]; memo }
  end
end

{'fraction_non_alphanumeric': 0.10724365004703669, 'fraction_numerical': 0.0, 'mean_word_length': 3.172549019607843, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1349604', 'n_tokens_mistral': 352, 'n_tokens_neox': 348, 'n_words': 92}