For Kotlin, you can use this function
fun sortList(list: List<YourCustomPOJOClass?>) {
//descending
Collections.sort(
list
) { o1, o2 -> Integer.valueOf(o1!!.intValueXYZ!!).compareTo(o2!!.intValueXYZ!!) }
// //ascending
// Collections.sort(
// list
// ) { o1, o2 -> Integer.valueOf(o2!!.intValueXYZ!!).compareTo(o1!!.intValueXYZ!!) }
}
and just call it in your activity
or fragment
by
sortList(list)