//list:在数据查询出来的Record集合
//juli:是需要比较的字段  
//实现一个Comparator接口
//后面减去前面是正序   前面减去后面是倒叙
//我这里做的一个距离排序 Record对应你需要对比的实体
List<Record> list = ljRoutePlan.getPlanDistance(lng, lat , distance*1000);
        Collections.sort(list,new Comparator<Record>(){
            @Override
            public int compare(Record o1, Record o2) {
                return o1.getDouble("juli").compareTo(o2.getDouble("juli"));
            }
        });
 
少写点bug,多一点美好。

compare正序与逆序的更多相关文章

  1. Comparable 接口学习:对对象List进行比较和排序(正序和逆序)

    Comparable 接口只有一个 int compareTo(T o) 方法 1.int compareTo(T o) 方法 方法说明: 比较此对象和规定的对象,如果此对象大于,等于,小于规定对象, ...

  2. Python九九乘法表(正序和逆序)

    正序: for i in range(1,10): for j in range(1,i+1): print(str(i)+"*"+str(j)+"="+str ...

  3. Java之选择排序(正序、逆序)

    public class SelectSort { public static void main(String[] args) { /** * @author JadeXu * @// TODO: ...

  4. map正序、逆序排序

    一.按 key 排序 1.map顺序排序(小的在前,大的在后): map<float,string,less<float> > m_aSort;//已float从小到大排序 2 ...

  5. 5, java数据结构和算法: 栈 , 入栈, 出栈, 正序遍历,,逆序遍历

    直接上代码: class ArrayStack{ //用数组模拟栈 int maxSize; int[] stack; int top = -1;//表示栈顶 public ArrayStack(in ...

  6. 笔记-NSArray 逆序reverseObjectEnumerator 及 NSEnumerator 遍历

    //1.原始数组 NSMutableArray *array = [NSMutableArray arrayWithObjects:@"1",@"2",@&qu ...

  7. Java的数组和list升序,降序,逆序函数Collections.sort和Arrays.sort的使用

    list升序,降序,逆序List<Integer>list =new ArrayList<Integer>();//如果list是 5 7 2 6 8 1 41.升序:Coll ...

  8. Java 数组元素逆序Reverse的三种方式

    Java 数组元素逆序Reverse的三种方式   本文链接:https://blog.csdn.net/xHibiki/article/details/82930521 题目 代码实现 说明 int ...

  9. C#数组的排序(正序逆序)

    C#数组的排序(正序逆序) 这种排序 超级简单的 ! using System; using System.Collections.Generic; using System.Linq; using ...

随机推荐

  1. 11.11如何卖到一个亿:从0到1的电商爆品打造术 电子书 PDF

    内容转自:https://download.csdn.net/download/chenyao1994/11191034 下载地址:https://pan.baidu.com/s/1uQ1cjm9QH ...

  2. 环形缓冲区: ringbuf.c

    #cat aa.c /*ringbuf .c*/ #include<stdio.h> #include<ctype.h> #define NMAX 8 int iput = 0 ...

  3. copy.c实现

    #cat copy.c #include <stdio.h> #include <stdlib.h> #include <string.h> int copyFil ...

  4. js 输入框只能输入 1-7 的数字

    $jq(function () { $jq("#XSCM_WORKDAY").keyup(function () { //如果输入非数字,则替换为'',如果输入数字,则在每4位之后 ...

  5. MySQL之中文乱码问题

    创建 my.ini 文件,在该文件中添加以下内容,放在安装好的mysql根路径下: [client] default-character-set=utf8 [mysql] # 设置mysql客户端默认 ...

  6. LeetCode 712. Minimum ASCII Delete Sum for Two Strings

    Given two strings s1, s2, find the lowest ASCII sum of deleted characters to make two strings equal. ...

  7. BUAA_OO_博客作业二

    1.作业设计策略 1.1第一次作业 ​ 第一次作业指导书要求是一个单部多线程傻瓜调度(FAFS)电梯的模拟,由于为了可扩展性和模块化设计,第一次作业我采用了三线程,即输入处理线程,调度器线程,电梯线程 ...

  8. 【codeforces 792C】Divide by Three

    [题目链接]:http://codeforces.com/contest/792/problem/C [题意] 让你删掉最少的数字使得剩下的数字%3==0 [题解] 看代码..内置题解了现在. [完整 ...

  9. [C++基础]goto的用法

    原文: http://blog.csdn.net/shimazhuge/article/details/8448773 ---------------------------------------- ...

  10. 前台JSON对象传给springmvc,解析为map对象

    前台JSON对象传给springmvc,解析为map对象 javascript: $.ajax({ url : url, method : 'post', contentType : 'applica ...