net.wicp.tams.component.tools.CompartorJson Maven / Gradle / Ivy
package net.wicp.tams.component.tools;
import java.util.Comparator;
import org.apache.tapestry5.json.JSONObject;
/*****
* 比较两个 JSONObject 对象,这两个对象必须都有 index 域
*
* @author 周俊辉
*
*/
public class CompartorJson implements Comparator {
@Override
public int compare(JSONObject o1, JSONObject o2) {
if (o1.has("index") && o2.has("index")) {
return o1.getInt("index") - o2.getInt("index");
}
return 0;
}
}