Hey I want to distinctBy and sort by in kotlin. I did this successfully without any problem, I want to know is there any better way in data structure which helps in better performance, time and space complexity in efficient manner to do that. Can someone guide me.
val filteredTopics by lazy { MutableStateFlow<List<Topics>>(emptyList()) }
fun createData(private val list: ArrayList<Category>) {
filteredTopics.value = list
.flatMap { it.topics!! }
.distinctBy { topic -> topic.title }
.sortedBy { topic -> topic.title }
}