comparator

    3热度

    3回答

    我已经创建了一个自定义比较器来排序字符串ArrayList。我通过调试器运行它,并观察它是否正确地比较和返回值。但是,我的数组没有排序。由于我是Android的新手,可能还有其他的事情发生。 看了它几个小时后,我无法弄清楚什么......因为我一直在使用这个网站来回答很多其他问题,所以我知道要去哪里! Collections.sort(allWords, new Comparator<String

    0热度

    1回答

    我有一个拥有4个成员的java对象列表。 int id; String name; String age; int order; 我使用他的代码,根据如果条件按升序排列对象字段进行排序。 Collections.sort(list, new Comparator<com.MyObject>() { public int compare(com.MyObject objec

    6热度

    6回答

    如果我有以下类: public class Employee { private int empId; private String name; private int age; public Employee(int empId, String name, int age) { // set values on attributes

    0热度

    1回答

    我有这个功能比较版本号: def version_gt(left, right): """ Compare two version numbers telling which is greater Returns True if left is greater, False if right is greater. """ left = map

    1热度

    2回答

    我正在尝试按发布日期对相册进行排序。由于某种原因,我没有得到任何地方: //sort by release date Collections.sort(this._items, new Comparator<Album>() { public int compare(Album t1, Album t2) { int dateCmp = t2.getStartDate().

    9热度

    3回答

    我在做一个TreeMap<String, String>并且想要以降序方式订购它。我创建了以下比较: Comparator<String> descender = new Comparator<String>() { @Override public int compare(String o1, String o2) { return o2.compareTo(o

    4热度

    5回答

    如果我要求已经回答的问题,但是找不到参考,我很抱歉。我的问题是放哪个图层属于哪个比较器的最佳位置。例如,我需要一个按用户排序的用户对象列表,这些用户对象按照出生日期,姓氏和名字排序。

    5热度

    3回答

    int compare(Object o1,Object o2) 比较它的两个参数的顺序。 对于比较两个对象O1和O2需要做这样的事情: MyClass o1=new MyClass(); MyClass o2=new MyClass(); if (o1.compare(o1,o2)>0) ...... 为什么这个methtod不是一成不变的? 如果方法是静态的可能,如: if (MyC

    4热度

    1回答

    我使用我之前声明的比较器调用ArrayList上的Collections.sort()。 ArrayList<Employee> list = new ArrayList<Employee>(); Comparator<Employee> comparator = new Comparator<Employee>() { public int compare(Employee o1,

    0热度

    3回答

    我有一个类型为A的对象列表,而且我必须为它的类型为String的字段命令它。 public class A{ public String field1; public Integer field2; ... } 如果我不得不下令对INT领域早就这样做了: Collections.sort(listOfA, new Comparator<A>() {