Java 不在Android上工作的排序

Java 不在Android上工作的排序,java,android,arrays,Java,Android,Arrays,我在我的clas新闻上实现了Comparable,这样我就可以按publishDate安排一系列新闻 import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; public class News implements Comparable<News>{ private String title;

我在我的clas新闻上实现了Comparable,这样我就可以按publishDate安排一系列新闻

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;


public class News implements Comparable<News>{

    private String title;
    private String description;
    private String link;
    private String guid;
    private String pubDate;
    private Date date;
    private String author;
    private String image;
    private String category;
    private String feedIconLink;



    @Override
    public int compareTo(News anotherNews) {

        long compareDateInMilisecconds = ((News) anotherNews).getDateInMilliseconds();

        long result = compareDateInMilisecconds - this.getDateInMilliseconds();

        int finalResult = (int) result;

        return finalResult;
    }
import java.text.ParseException;
导入java.text.simpleDataFormat;
导入java.util.Date;
导入java.util.Locale;
公共类新闻工具{
私有字符串标题;
私有字符串描述;
私有字符串链接;
私有字符串guid;
私有字符串发布日期;
私人日期;
私有字符串作者;
私有字符串图像;
私有字符串类别;
私有字符串feedIconLink;
@凌驾
公共国际比较(新闻与其他新闻){
long comparedateInMiliseConds=((新闻)另一条新闻).getDateInMillistics();
long result=comparedateInMiliseConds-this.getDateInMillicles();
int finalResult=(int)结果;
返回最终结果;
}
代码编译并运行,不会出错,但实际上不会更改数组中对象的顺序

 @Override
        protected void onPostExecute(List<News> input) {

            for (News aNews : input){
                Log.v("Before", aNews.getFeedIconLink());
            }

            Arrays.sort(input.toArray());

            for (News aNews : input){
                Log.v("After", aNews.getFeedIconLink());

            }

            this.listener.finish(input);
            }
@覆盖
受保护的void onPostExecute(列表输入){
for(新闻:输入){
Log.v(“Before”,aNews.getFeedIconLink());
}
Arrays.sort(input.toArray());
for(新闻:输入){
Log.v(“After”,aNews.getFeedIconLink());
}
this.listener.finish(输入);
}
我在排序之前和之后都使用Log.v,并且没有任何更改,即使在调试时,它在整个数组的整个CompareTo方法中运行

我做错什么了吗?

你是:

  • 列表
    转换为
    新闻[]

  • 新闻[]进行排序

  • 扔掉
    新闻[]

而是对
列表进行排序,而不是对
数组进行排序。sort()