What is the most optimized way to compare two ArrayLists of different object type? Let's say I have an Array Lists of Remedies and Adherences and them being:

**ObjectA**

```
data class ObjectA(val data: List<Objecta> = emptyList()) {

    data class Objecta(
        val _id: String,
        val remedy_id: String,
        val patient_id: String,
        val date_created: Long,
        val is_ongoing: Boolean?,
        val start_date: Long,
        val medicine_id: String,
        val instruction: String,
        val medicine_name: String,
        val medicine_type: String,
        val end_date: Long,
        val repeat_cycle: Int,
        val allow_edit: Boolean,
        //val schedule: List<Schedule>?,
        val is_current: Boolean,
        //val medicine: Medicine?,
        val price: Float
    )
}

```

**ObjectB**

```
data class ObjectB(val data: List<Objectb> = emptyList()) {

    data class Objectb(
        val _id: String,
        val adherence_id: String,
        val patient_id: String,
        val remedy_id: String,
        val alarm_time: String,
        val action: String,
        val action_time: String,
        val dose_discrete: String,
        val dose_quantity: Int,
        val note: String
    )
}

```

How can I compare both those two array lists "remedyList" and "adherencesList" where remedy\_id is the same and remove items in adherencesList when remedy\_id is not present in remedyList.