0

我正在使用 json 解析获取航班数组列表,现在我想按纬度和经度对这个数组列表进行排序,但是我该如何排序我知道简单的列表排序,但不知道数组列表

主页 Activity.java

@override
public class HomeActivity extends  Activity
{
    public void oncreate { 

     new FlightListBack.execute();

}

public class FlightListBack extends AsyncTask<String,ArrayList< HashMap<String,String>>, ArrayList<HashMap<String,String>>> 
{
    @Override
    protected ArrayList<HashMap<String,String>> doInBackground(
            String... params) {
    try
        {
        String spinnerstringfunction=jparser.getJSONFromUrl(airporturl);
        Log.e("SpinnerStringFunction","Count"+spinnerstringfunction);

        JSONObject jobject= new JSONObject(spinnerstringfunction); 

        // Airlines Array For Getting Airlines Name
        sjairport=jobject.getJSONArray(TAG_SAIRPORT);

        Log.e("Aysn sjairport","sss"+sjairport);
        for(int a=0;a<sjairport.length();a++)
        {

            HashMap<String, String> spinnermap = new HashMap<String, String>();
            String spinnerfs=sjairport.getJSONObject(a).get(TAG_SPINNERFS).toString(); 
            String spinnername=sjairport.getJSONObject(a).get(TAG_SPINNERNAME).toString();
            String  spinnercity=sjairport.getJSONObject(a).get(TAG_SPINNERCITY).toString();
            String slatitude=sjairport.getJSONObject(a).get(TAG_SPINNERLATITUDE).toString();
            String slongitude=sjairport.getJSONObject(a).get(TAG_SPINNERLONGITUDE).toString();

            spinnermap.put(TAG_SPINNERFS, spinnerfs);
            spinnermap.put(TAG_SPINNERNAME,spinnername);
            spinnermap.put(TAG_SPINNERCITY,spinnercity);
            spinnermap.put(TAG_SPINNERLATITUDE,slatitude);
            spinnermap.put(TAG_SPINNERLONGITUDE, slongitude);

            spinnerAirportList.add(spinnermap);  

        }

        Log.e("Spinner Airport List","spinner"+spinnerAirportList);

    }
    catch (Exception e)
    {
            e.printStackTrace();
    }

    return spinnerAirportList;

}
protected void onPostExecute(final ArrayList<HashMap<String, String>> result )
{
          other code for display listview

}
}
4

0 回答 0