mirror of
https://github.com/Team4388/RidgeScout.git
synced 2026-06-09 00:37:59 -06:00
25 lines
592 B
Java
25 lines
592 B
Java
|
|
package com.astatin3.scoutingapp2025.ui;
|
||
|
|
|
||
|
|
import org.json.JSONArray;
|
||
|
|
|
||
|
|
import java.util.ArrayList;
|
||
|
|
import java.util.Collections;
|
||
|
|
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));
|
||
|
|
}
|
||
|
|
Collections.sort(asList, c);
|
||
|
|
JSONArray res = new JSONArray();
|
||
|
|
for (Object o : asList){
|
||
|
|
res.put(o);
|
||
|
|
}
|
||
|
|
return res;
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|