Collections.sort(vecALL);不知道可不可以

解决方案 »

  1.   

    java.util.Collections.sort(vector);
    在java 2 中建议用ArrayList代替Vector
      

  2.   

    Collections.sort
    static void sort(List list) 
              Sorts the specified list into ascending order, according to the natural ordering of its elements. 
    static void sort(List list, Comparator c) 
              Sorts the specified list according to the order induced by the specified comparator. 
      

  3.   

    自己写个class,implement comparor在调用这个class的一些方法
      

  4.   

    vector本身不能排序.你可以在vecResult放到vecAll中的时候按排序啊.
      

  5.   

    to :wubai250(wubai)
        结果集不能排序那我用其他的方法可以完成吗
      

  6.   

    to: qyzj(市长来访)
        是啊,不能直接排序就只能这样了,不过我感觉很麻烦的,怎么做这个循环。我也是个初学者,所以希望大家多提意见
      

  7.   

    按照数据库中的table表里的一个时间字段进行排序?
    在数据提取时就(order by)时间字段,然后再进入Vector,就是已排好序!
      

  8.   

    to: stonecsdn(东东)& chancelin()
        这个方法怎么用啊,我用完后报错:
       java.lang.ClassCastException: [Ljava.lang.String;
    at java.util.Arrays.mergeSort(Arrays.java:1064)
    at java.util.Arrays.sort(Arrays.java:1014)
    at java.util.Collections.sort(Collections.java:78)
    请指教
      

  9.   

    to:hpy121(孩子) 
       先从表里读出一组数据,这组数据中min(时间)作为这组数据的的时间,然后在这些组里进行排序。而不是在组中排序,是在组与组之间。请指教
      

  10.   

    Vector不能排序
    但是list可以假设list里放了testobject对象,按testobject的xh(Integer)排序
    Collections.sort(list,new Comp());然后自己写个排序算法
    //排序算法,用于对fymx对象按xh字段排序
      static class Comp implements Comparator{
        public int compare(Object f1,Object f2){
          testObject fmo1=(testObject)f1;
          testObject fmo2=(testObject)f2;
          Integer i1=fmo1.getXh();
          Integer i2=fmo2.getXh();
          return i1.compareTo(i2);
        }
      }如果要按时间排序 就写个时间排序的算法
      

  11.   

    楼上的有道理。先把所有vector都转化为list,再排序。
      

  12.   

    to dvictor(大学之道 在明明德) :如果是按汉字排序应该怎么写啊 !谢谢 !
      

  13.   

    汉字排序 用Collections.sort(list)就可以了
      

  14.   

    从楼主的意思来说,你怎么不从数据库拿出来的时候用sql来解决呢?