mirror of
https://github.com/Team4388/RidgeScout.git
synced 2026-06-09 00:37:59 -06:00
24 lines
552 B
Java
24 lines
552 B
Java
package com.ridgebotics.ridgescout.utility;
|
|
|
|
import org.json.JSONArray;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.Comparator;
|
|
import java.util.List;
|
|
|
|
public class JSONUtil {
|
|
public static JSONArray sort(JSONArray array, Comparator c){
|
|
List asList = new ArrayList(array.length());
|
|
for (int i=0; i<array.length(); i++){
|
|
asList.add(array.opt(i));
|
|
}
|
|
asList.sort(c);
|
|
JSONArray res = new JSONArray();
|
|
for (Object o : asList){
|
|
res.put(o);
|
|
}
|
|
return res;
|
|
}
|
|
|
|
}
|