我需要arraylist
根据另一个数组对几个进行排序,但真的不知道如何去做。我有列表距离,我使用集合对其进行排序。这工作得很好,但我想根据排序列表对我的其他列表进行排序。这是我到目前为止所做的
private void sortList() {
List<Float> tempDistance = new ArrayList<Float>();
List<Float> tempmyLat = new ArrayList<Float>();
List<Float> tempmyAlt = new ArrayList<Float>();
List<Float> tempmyLng = new ArrayList<Float>();
ArrayList<HashMap<String, String>> tempplacesListItems = new ArrayList<HashMap<String, String>>();
tempDistance = Distance;
tempmyLat = myLat;
tempmyLng = myLng;
tempmyAlt = myAlt;
tempplacesListItems = placesListItems;
Collections.sort(tempDistance);
for (int i = 0; i < Distance.size(); i++) {
Log.d("sorted distance", "" + tempDistance.get(i));
for (int k = 0; k < tempDistance.size(); k++) {
if (Distance.get(i) == tempDistance.get(k)) {
tempplacesListItems.set(k, placesListItems.get(i));
tempmyLat.set(k, myLat.get(i));
tempmyLng.set(k, myLng.get(i));
tempmyAlt.set(k, myAlt.get(i));
}
}
}
myLat = tempmyLat;
myLng = tempmyLng;
myAlt = tempmyAlt;
placesListItems = tempplacesListItems;
}