I have MutableLiveData> in ViewModel. How can we sort it based on book name, id and so on.
You can use map
function to transform your LiveData
.
val unsortedBooks: LiveData<Book> = //...
val sortedBooks: LiveData<Book> = Transformations
.map(unsortedBooks, Function { books ->
//sort your `books` here and return the sorted list
})