interface Feed
class Memo : Feed {
var memoId: String? = null
var updateTime: String? = null
// other fileds
}
class Activity : Feed {
var activityId: String? = null
var updateTime: String? = null
// other fileds
}
As above code, I have Created one interface and extend it in the other two classes.
var mainFeedList: ArrayList<Feed> = ArrayList()
var memoList: ArrayList<Memo> = ArrayList()
var ActivityList: ArrayList<Activity> = ArrayList()
fun arrangeFeedDataOrder() {
mainFeedList.addAll(memoList)
mainFeedList.addAll(ActivityList)
mainFeedList.sortedBy {
when (it) {
is Activity -> {
it.updateTime
}
is Memo -> {
it.updateTime
}
else -> {
null
}
}
}
// Not work above code for sorting
}
I have the main list which contains memos and activity data. I want to sort this list with updateTime filed. I used sortedBy function but it does not work in my case. Anyone has an idea how to sort the list?