Advertisement

Android Studio: Sort Array Lists Using Comparable and Comparator interfaces

Android Studio: Sort Array Lists Using Comparable and Comparator interfaces In this video we will see how to make an object comparable and sort the array lists using the comparable and comparator interfaces.

To make an object comparable, we need to implement either the comparable interface and implement the compareTo method, or use the Comparator interface and implement its compare method.

In this video we work with in Item object, which can be sorted by id, price and object name.

You might need to sort an array lists in various cases, for example: to rearrange the order of a list that feeds your Recycler View component.

If you have any questions and comments, please leave them in the section below.

Thank you for watching!

android studio,android tutorial,android java language,sort an array,sort array lists,use the comparable interface,use the comparator interface,implement comparable interface,implement comparator interface,array list ascending order,array list descending order,sorting in android,

Post a Comment

0 Comments