Android sort ArrayLit<class> in API16?

ZeroKat :

I´m doing an assignment and it´s required to support API16.

My view is a custom ArrayListAdapter with takes an

ArrayList<someclass>

The problem is that I want to make it possible to sort the data the user has put in the list.

items.sort(new Comparator<someclass>() {
    @Override
    public int compare(someclass item1, someclass item2) {
        return item1.Name.compareTo(item2.Name);
    }
});

But when I try Android Studio tells that I need API 24.

how do I sort the list in API 16?

lelloman :

You can use Collections.sort

Collections.sort(items, new Comparator<someclass>() {
    @Override
    public int compare(someclass item1, someclass item2) {
        return item1.Name.compareTo(item2.Name);
    }
});

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=467286&siteId=1