You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: case_contacts_contact_dates.rb
    path of file: ./repos/casa/app/services
    
    the code of the file until where you have to start completion: class CaseContactsContactDates
  def initialize(case_contact_contact_types)
    @case_contact_contact_types = case_contact_contact_types
  end

  def contact_dates_details
    contact_type_names = @case_contact_contact_types.map(&:contact_type).map(&:name).uniq # .sor
    
  def contact_dates_details
    contact_type_names = @case_contact_contact_types.map(&:contact_type).map(&:name).uniq # .sort # TODO sort after refactor
    contact_type_names.map do |contact_type_name|
      case_contacts = case_contacts_for_type(contact_type_name)

      {
        name: "Names of persons involved, starting with the child's name",
        type: contact_type_name,
        dates: order_and_format(case_contacts),
        dates_by_medium_type: case_contacts.group_by(&:medium_type).transform_values { |vals| order_and_format(vals) }
      }
    end
  end