开发者

Android sort array

how can i sort this array by date or name?

String[][] datetable= new String[21][2];

datetable[0][0] = "2011.01.01";
datetable[0][1] = "Name1";
datetable[1][0] = "2011.01.03";
datetable[1][1] = "Name2";
.
.
.
datetable[20开发者_JAVA百科][0] = "2011.02.16";
datetable[20][1] = "Name3";


I would do what the poster linked to, only I wouldn't use final so much.

Arrays.sort(datetable, new Comparator<String[]>() {
    @Override
    public int compare(String[] entry1, String[] entry2) {
        // Sort by date
        return entry1[0].compareTo(entry2[0]);
    }
});


This may help: Sort a two dimensional array based on one column

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜