开发环境(蓝色粗体字为特别注意内容)
1、软件环境: Win7 Ultimate sp1、jdk7u45
其实在Java中有一个很方便的列表排序方式,那就是
Collections.sort(mList);
其中mList<Bean>的实体类Bean中实现排序逻辑:
比如
package com.*;
import java.util.List;
public class Bean implements Comparable<Bean> {
private int index;
private String code;
public int getIndex() {
return index;
}
public void setIndex(int index) {
this.index = index;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
@Override
public int compareTo(Bean another) {
return this.getIndex() - another.getIndex();
}
}