-1

I am new to android development..please forgive me .. I have a recycler view with photo and video I want to arrange photo according to likes that photo as got ...

the photo which as more like should be in top ...can you help me please ....

** I was using this code for comparing photo by date **

      Collections.sort(mPhotos, new Comparator<Photo>() {
                @Override
                public int compare(Photo o1, Photo o2) {

                    return o2.getDate_created().compareTo(o1.getDate_created());
                }
            });
  • 1
    Possible duplicate of [Sorting List<> by numeric value](https://stackoverflow.com/questions/11206495/sorting-list-by-numeric-value) – Milan Pansuriya Jun 25 '18 at 10:25

1 Answers1

0

I think we can do it in below for format

    /*
     * SORT
     */
    private void sortData(boolean ascending)
    {
        //SORT ARRAY ASCENDING AND DESCENDING
        if (asc)
        {
            Collections.sort(likes);
        }
        else
        {
            Collections.reverse(likes);
        }

for more details Please visit the Below URL

http://camposha.info/source/android-recyclerview-sort-ascendingdescending

Anbu
  • 671
  • 1
  • 6
  • 18
  • bro thanks for your answer ..you have shown to sort in ascending and descending but I want it ti sort in like 5 4 3 2 1 not like 1 3 5 2 4 –  Jun 25 '18 at 10:56
  • should I create my own algorithm –  Jun 25 '18 at 10:58