Android Collections排序相关问题(难道就没人会了吗???)

#下面代码Collections中如何根据照片的经纬度来进行排序?#

    /**
     * 按照地点进行分组
     * @param context
     * @param list
     * @return
     */
    public static List<GroupEntity> setAddressOrder(Context context, List<ParentEntity> list) {
        if (list == null || list.isEmpty()) {
            return null;
        }

        //排序前
        for (int i = 0; i < list.size(); i++) {
            String address = LocationUtil.queryLatLongItudeLocation(context,
                    list.get(i).getLatitude(), list.get(i).getLongitude());
            if(address != null){
                Log.e("===>>>", address);
            }
        }

        Collections.sort(list, new Comparator<ParentEntity>() {
            @Override
            public int compare(ParentEntity lhs, ParentEntity rhs) {
                if(1 < Math.abs(lhs.getLatitude() - rhs.getLatitude()) 
                        && 1 < Math.abs(lhs.getLongitude() - rhs.getLongitude())){
                    return 2;
                }else{
                    return 0;
                }
            }
        });

        //排序后
        for (int i = 0; i < list.size(); i++) {
            String address = LocationUtil.queryLatLongItudeLocation(context,
                    list.get(i).getLatitude(), list.get(i).getLongitude());
            if(address != null){
                Log.e("===>>>", address);
            }
        }

        List<GroupEntity> entlist = new ArrayList<GroupEntity>();
//      GroupEntity group = null;//用来存储数据
//      for (int i = 0; i < list.size(); i++) {
//          ParentEntity entity = list.get(i);
//          
//          if (group == null 
//                  || 1 < Math.abs(group.latitude - entity.getLatitude()) 
//                  && 1 < Math.abs(group.longitude - entity.getLongitude())) {
//              group = new GroupEntity();//不相同新建放入
//              group.latitude = entity.getLatitude();
//              group.longitude = entity.getLongitude();
//              entlist.add(group);
//          }
//          group.list.add(entity);
//      }
        return entlist;
    }

自己解决!!!

    /**
     * 按照地点进行分组
     * 
     * @param context
     * @param list
     * @return
     */
    public static List<GroupEntity> setAddressOrder(Context context,
            List<ParentEntity> list) {
        if (list == null || list.isEmpty()) {
            return null;
        }
        List<ParentEntity> temp = new ArrayList<ParentEntity>(list);
        List<GroupEntity> result = new ArrayList<GroupEntity>();
        while (!temp.isEmpty()) {
            GroupEntity ge = new GroupEntity(temp.remove(0));
            for (ParentEntity e : temp) {
                if (0.5 > Math.abs(ge.latitude - e.getLatitude())
                        && 0.5 > Math.abs(ge.longitude - e.getLongitude())) {
                    ge.list.add(e);
                }
            }
            temp.removeAll(ge.list);
            result.add(ge);
        }
        return result;
    }