Mercurial > hg > AnnotationManagerN4J
view src/main/java/de/mpiwg/itgroup/annotations/restlet/utils/JSONObjectComparator.java @ 28:f4ed2ed33e5b
Restinterface zur Anzeige von Tags hinzugefuegt-
author | dwinter |
---|---|
date | Tue, 25 Sep 2012 09:32:56 +0200 |
parents | |
children | 9f653697437e |
line wrap: on
line source
package de.mpiwg.itgroup.annotations.restlet.utils; import java.util.Comparator; import de.mpiwg.itgroup.annotations.Annotation; import org.json.JSONException; import org.json.JSONObject; public class JSONObjectComparator implements Comparator<JSONObject>{ private String attributeToSort; public JSONObjectComparator(String attribute){ this.attributeToSort=attribute; } public int compare( JSONObject a, JSONObject b ) { // je quadratischer, desto grösser String sortA; try { sortA = a.getString(attributeToSort); } catch (JSONException e) { sortA =""; } String sortB; try { sortB = b.getString(attributeToSort); } catch (JSONException e) { sortB=""; } return sortA.compareToIgnoreCase(sortB); } }