'Sort list view by date in kotlin

I have this code and I want to sort this filesList by date, can anyone tell how to do it?

        val filesList = Dao().getData(path, requireContext())
        println(path)
        val recyclerView = view.findViewById<RecyclerView>(R.id.statusRecyclerView)
        recyclerView.layoutManager = StaggeredGridLayoutManager(3,StaggeredGridLayoutManager.VERTICAL)
        val adapter = StatusAdapter(requireContext(), filesList)
        recyclerView.adapter = adapter
        adapter.notifyDataSetChanged()
    }


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source