1.正序
val list: MutableList<CommentBean> = mutableListOf()
list.sortByDescending { it.time }
2.倒序
val list: MutableList<CommentBean> = mutableListOf()
list.sortByDescending { it.time }
data class CommentBean(
var id: Long = 0,
var userBean: UserBean,
var content: String = "",
var praiseNum: Int = 0,
var score: Double = 0.0,
var time: Long = 0L,
var isPraise: Boolean = false,
var commentList: MutableList<CommentBean> = mutableListOf(),
var commentSize: Int = 0
)
data class UserBean(
var uid: Long,
var head: String? = null,
var gender: String? = null,
var age: String? = null,
var birth: String? = null,
var city: String? = null,
var id: String? = null,
var desc: String? = null,
var headBg: String? = null,
var name: String? = null
)
网友评论