There is a class name recording with parameters song, artist, and playtime
class Recording {
var title: String
var artists: String
var playingTime: Int
constructor(t: String, a: String, p: Int) {
title = t
artists = a
playingTime = p
}
}
I have a mutable list of objects,I need to sort this based on each parameter ie song, artist, and playtime.
var list = mutableListOf<Recording>(
Recording("Sorry", "Justin Bieber", 420),
Recording("a", "a", 1),
Recording("b", "b", 2)
)
val sortedList = list.sortedWith(compareBy({ it.title.toLowerCase() }, { it.artists.toLowerCase() }, {it.playingTime}))