开发者

Help sort to list by date

开发者 https://www.devze.com 2023-02-19 05:24 出处:网络
I have an array list sorted from oldest to newest. I want to change it so that it is sorted from newes开发者_高级运维t to oldest. Can anyone help me?Sounds like you want to reverse the order of an arr

I have an array list sorted from oldest to newest. I want to change it so that it is sorted from newes开发者_高级运维t to oldest. Can anyone help me?


Sounds like you want to reverse the order of an array?

Collections.reverse(yourSortedList);

See Android docs


This is just a java question rather than Android:

    ArrayList<String> originalList = new ArrayList<String>();
    ArrayList<String> newList = new ArrayList<String>();

    for(int i = originalList.size(); i > 0 ; i--) {
        newList.add(originalList.get(i));
    }

I'm sure there are other ways that differ that can be discussed.

0

精彩评论

暂无评论...
验证码 换一张
取 消