Sorting a vector

hi
all i am having problem with sorting a vector.I have a vector which contain Objects and each object has string values
Vector->Objects->String 1 string 2 string 3;
now i want to sort by string 2 but i also want to sort it by string 3 i means vector should be able to sort by string 2 and second preriority to string 3 and then string1.
How can i do this i am over loading the comparator class.
Collection.sort(vector, new vecComparetor());
public int compare(Object obj1, Object obj2) {
retrun obj1.compareTo(obj2);
}

If I guessed correctly your class is something like the following:
package mydomain;
public class MyClass{
     private String str1, str2, str3;
     public MyClass( String str1, String str2, String str3){
          this.str1 = str1;
          this.str2 = str2;
          this.str3 = str3;
     public String getStr1(){ return str1;}
     public String getStr2(){ return str2;}
     public String getStr3(){ return str3;}
     public String toString(){ return "(" + str1 + ", " + str2 + ", " + str3 + ")";}
}Now, your problem is: Order Vector of MyClass objects by str2, then by str1, then by str3.
So here it is your Comparator:
package utils;
import mydomain.MyClass;
import java.util.Comparator;
public class MyComparator implements Comparator{
     public int compare( Object o1, Object o2){
          int i = 0;
          return (i = ((MyClass)o1).getStr2().compareTo( ((MyClass)o2).getStr2())) != 0? i:
                ((i = ((MyClass)o1).getStr1().compareTo( ((MyClass)o2).getStr1())) != 0? i:
                ((i = ((MyClass)o1).getStr3().compareTo( ((MyClass)o2).getStr3())) != 0? i: 0));
}Try it out with this tester (cut and paste these three classes. They compile and run.):
package utils;
import mydomain.MyClass;
import java.util.Vector;
import java.util.Collections;
public class MyComparatorTest{
     public static void main( String[] args){
          Vector v = new Vector();
          for( char x = 'a'; x <= 'c'; x++){
               for( char y = 'a'; y <= 'c'; y++){
                    for( char z = 'a'; z <= 'c'; z++){
                         v.add( new MyClass( new Character( x).toString(), new Character( y).toString(), new Character( z).toString()));
          System.out.println( v);
          Collections.sort( v, new MyComparator());
          System.out.println( v);
}

Similar Messages

  • How to sort a Vector that stores a particular object type, by an attribute?

    Hi guys,
    i need help on this problem that i'm having. i have a vector that stores a particular object type, and i would like to sort the elements in that vector alphabetically, by comparing the attribute contained in that element. here's the code:
    Class that creates the object
    public class Patient {
    private String patientName, nameOfParent, phoneNumber;
    private GregorianCalendar dateOfBirth;
    private char sex;
    private MedicalHistory medHistory;
    public Patient (String patientName, String nameOfParent, String phoneNumber, GregorianCalendar dateOfBirth, char sex) {
    this.patientName = patientName;
    this.nameOfParent = nameOfParent;
    this.phoneNumber = phoneNumber;
    this.dateOfBirth = dateOfBirth;
    this.sex = sex;
    this.medHistory = new MedicalHistory();
    Class that creates the Vector.
    public class PatientDatabase {
    private Vector <Patient> patientDB = new Vector <Patient> ();
    private DateFunction date = new DateFunction();
    public PatientDatabase () throws IOException{
    String textLine;
    BufferedReader console = new BufferedReader(new FileReader("patient.txt"));
    while ((textLine = console.readLine()) != null) {
    StringTokenizer inReader = new StringTokenizer(textLine,"\t");
    if(inReader.countTokens() != 7)
    throw new IOException("Invalid Input Format");
    else {
    String patientName = inReader.nextToken();
    String nameOfParent = inReader.nextToken();
    String phoneNum = inReader.nextToken();
    int birthYear = Integer.parseInt(inReader.nextToken());
    int birthMonth = Integer.parseInt(inReader.nextToken());
    int birthDay = Integer.parseInt(inReader.nextToken());
    char sex = inReader.nextToken().charAt(0);
    GregorianCalendar dateOfBirth = new GregorianCalendar(birthYear, birthMonth, birthDay);
    Patient newPatient = new Patient(patientName, nameOfParent, phoneNum, dateOfBirth, sex);
    patientDB.addElement(newPatient);
    console.close();
    *note that the constructor actually reads a file and tokenizes each element to an attribute, and each attribute is passed through the constructor of the Patient class to instantiate the object.  it then stores the object into the vector as an element.
    based on this, i would like to sort the vector according to the object's patientName attribute, alphabetically. can anyone out there help me on this?
    i have read most of the threads posted on this forum regarding similar issues, but i don't really understand on how the concept works and how would the Comparable be used to compare the patientName attributes.
    Thanks for your help, guys!

    Are you sure that you will always sort for the patient's name throughout the application? If not, you should consider using Comparators rather than implement Comparable. For the latter, one usually should ensure that the compare() method is consistent with equals(). As for health applications it is likely that there are patients having the same name, reducing compare to the patient's name is hazardous.
    Both, Comparator and Comparable are explained in Sun's Tutorial.

  • Sorting a vector of objects?

    I'm having a real hard time sorting my vector, which contains objects that are made up of 4 Strings and 1 integer each.
    This is what I have for the sort routine, but something needs to go in the line that has "if (current.compareTo(smallest) < 0 )" to make it access the name fields of the current and smallest elements.
    Any ideas?
    Thanks,
    Mike
    private void sortname() {
         int nextslot;
         int max = cust_rex.size()-1;
         for (nextslot = 0; nextslot < max; nextslot++) {
              int j = getSmallestName(nextslot);
              swap (nextslot, j);
    private void swap(int a, int b) {
         Object temp = cust_rex.elementAt(a);
         cust_rex.setElementAt(cust_rex.elementAt(b),a);
         cust_rex.setElementAt(temp,b);
    private int getSmallestName (int k) {
         if (cust_rex == null || cust_rex.size() <= k)
              return -1; //error value
         int small = k;
         for (int i = k + 1; i < cust_rex.size(); i++) {
         Customer current = (Customer) cust_rex.elementAt(i);
         Customer smallest = (Customer) cust_rex.elementAt(small);
         if (current.compareTo(smallest) < 0 )
              small = i;
         return small;
         }

    Look at java.util.Comparator and write your own comparator. Then look at java.util.Collections and use the sort method from there instead of writing your own.

  • Sorting a vector of objects using attribute of object class as comparator

    i would like to sort a vector of objects using an attribute of object class as comparator. let me explain, i'm not sure to be clear.
    class MyObject{
    String name;
    int value1;
    int value2;
    int value3;
    i've got a Vector made of MyObject objects, and i would sort it, for instance, into ascending numerical order of the value1 attribute. Could someone help me please?
    KINSKI.

    Vector does not implement a sorted collection, so you can't use a Comparator. Why don't you use a TreeSet? Then you couldclass MyObject
      String name;
      int value1;
      int value2;
      int value3;
      // Override equals() in this class to match what our comparator does
      boolean equals (Object cand)
        // Verify comparability; this will also allow subclasses.
        if (cand !instanceof MyObject)
          throw new ClassCastException();
        return value1 = cand.value1;
      // Provide the comparator for this class. Make it static; instance not required
      static Comparator getComparator ()
        // Return this class's comparator
        return new MyClassComparator();
      // Define a comparator for this class
      private static class MyClassComparator implements Comparator
        compare (Object cand1, Object cand2)
          // Verify comparability; this will also allow subclasses.
          if ((cand1 !instanceof MyObject) || (cand2 !instanceof MyObject))
            throw new ClassCastException();
          // Compare. Less-than return -1
          if ((MyObject) cand1.value1 < (MyObject) cand2.value1))
            return -1;
          // Greater-than return 1
          else if ((MyObject) cand1.value1 > (MyObject) cand2.value1))
            return 1;
          // Equal-to return 0.
          else
            return 0;
    }then just pass MyObject.getComparator() (you don't need to create an instance) when you create the TreeSet.

  • Java.util.Arrays.sort for Vector

    I used the java.util.Arrays.sort to sort an array based on the method below.
                  java.util.Arrays.sort(array, 0, total, new ComparatorX());
               repaint();
                class ComparatorX implements java.util.Comparator
              public int compare( Object p1, Object p2){
                   int x1=((Point)p1).x;
                   int x2=((Point)p2).x;
                   if(x1>x2)
                                return 1;
                   if(x1>x2)
                                return -1;
                   return 0;
         }I've since changed the array to a vector. Is there anyway I can keep the comparator. Or how can I sort the vector based on the above method.

    BTW: Don't know if it's just a typing mistake, but your code contains an error:
    class ComparatorX implements java.util.Comparator     {
       public int compare( Object p1, Object p2) {
          int x1=((Point)p1).x;
          int x2=((Point)p2).x;
          if (x1>x2) {
             return 1;
          if (x1>x2) {  // Should be: if (x2 > x1) ...
             return -1;
          return 0;

  • Sorting a Vector by position in Alphabet

    Hey Folks,
    I have a Vector containing pairs of letters. e.g.
    ad
    ac
    de
    be
    bd
    Is it possible to sort the Vector by position in the Alphabet i.e. pairs beginning with 'a' are first, then those starting with 'b' etc... So would end up with something like:
    ac
    ad
    bd
    be
    de
    I'm not too bothered about the position of the second letter but would be a bonus if it was taken into consideration!
    Any help or suggestions would be great thanks.

    Please note that the code given sorts by Unicode value of the characters in the Strings (e.g. capital Z appears before lowercase a), NOT alphabetically. This may or may not be what you want.
    If you want to sort alphabetically (and/or for a specific locale), use a Collator as the second argument for the sort:Collections.sort(vector, Collator.getInstance(); // default locale of your machineorCollections.sort(vector, Collator.getInstance(Locale.US); // specific locale: US English

  • Sorting a Vector of Doubles

    Is there an API function to sort a vector of Doubles from least to greatest or vica versa, or would i need to do that manually?

    java.util.Collection class has method sort(List list) and method sort(List list, Comarator c) you could use either one of thes, since java.util.Vector implements interface List.
    probably if you use the version of sort without comparator, then it sorts in the ascending order, but if you want to sort in descending order, then you'd need to create your own custom comparator that causes list to be sorted the other way... (see documentations and APIs for other details -- docs and apis may be found through link in the left column of this page)

  • Sorting a vector of hashtables

    I have a vector of hashtables that I need to sort.
    The hashtables contain several keys such as FirstName, LastName, ID. I need to sort this vector by the values for the LastName and FirstName keys stored in the hashtables. For example...
    Vector containing the following three hashtables.
    hashtable1 = {FirstName = Jill, LastName = Smyth, ID=5}
    hashtable2 = {FirstName = James, LastName = Smith, ID=6}
    hashtable3 = {FirstName = Jill, LastName = Smith, ID=7}
    The vector needs to be sorted so the order is:
    Hashtable2 (James Smith)
    Hashtable3 (Jill Smith)
    Hashtable1 (Jill Smyth)
    Any ideas on how to do this efficiently?
    Any help would be much appreciated
    Thanks
    --Evan                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    Write a comparator which can determine if one hashtable is greater than another.
    Arrays.sort(myVector, myComparator);

  • Sort 2 Vector containg Objects

    I have 2 Vector , both contains objects
    I merge both the vector and make one Vector of Objects.
    Now i want to sort the Vector with the date filed.
    Can anybody write the code sorting the vector of objects on the basis of Date.?

    I have Vector name Employee( this contais object)
    Attribute: Name , Age , Date(on which user make entry:sysdate)
    like :
    Vector Employee= new Vector();
    Collections.sort(list,comparator);
    Plz help me how to use this Collections.sort(list,comparator);?
    What should be the code for comparator.?

  • Sorting a vector using the selection sort method

    I have to write a program that sorts a Vector using the selection sort algorithm. Unfortunately the textbook only has about 2 pages on vectors so needless to say I'm pretty clueless on how to manipulate vectors. However I think I'm on the right path, however I'm stuck on one part as shown in the code below.     
    private static void  selectionSort(Vector parts)
          int index;
            int smallestIndex;
            int minIndex;
            int temp = 0;
            for (index = 0; index < parts.size() - 1; index++)
              smallestIndex = index;
              for (minIndex = index + 1; minIndex < parts.size(); minIndex++)
               if (parts.elementAt(minIndex) < parts.elementAt(smallestIndex))  // this is where I'm having trouble
                  smallestIndex = minIndex;
                parts.setElementAt(temp, smallestIndex);
                parts.setElementAt(smallestIndex, index);
                parts.setElementAt(index, temp); if (parts.elementAt(minIndex) < parts.elementAt(smallestIndex))
    is returning "ProcessParts3.java:51: operator < cannot be applied to java.lang.Object,java.lang.Object"
    Here is the full program:
    import java.util.*;
    import java.io.*;
    public class ProcessParts3
         static Vector parts;
         public static void main(String[] args)
              loadVector();
         private static void loadVector()
         try
              Scanner fileIn = new Scanner(new File("productionParts.txt"));
              parts = new Vector();
              String partIn;
              while (fileIn.hasNext())
                   partIn = fileIn.nextLine();
                        parts.addElement(partIn.trim());
              selectionSort(parts);
                   for (int i = 0; i < parts.size(); i ++)
                   System.out.println(parts.elementAt(i));
         catch(Exception e)
              e.printStackTrace();
         private static void  selectionSort(Vector parts) //from this part down I'm responsible for the coding, everything
                                                               // everything above this was written by the teacher
                 int index;
            int smallestIndex;
            int minIndex;
            int temp = 0;
            for (index = 0; index < parts.size() - 1; index++)
                smallestIndex = index;
                for (minIndex = index + 1; minIndex < parts.size(); minIndex++)
                    if (parts.elementAt(minIndex) < parts.elementAt(smallestIndex))
                        smallestIndex = minIndex;
                parts.setElementAt(temp, smallestIndex);
                parts.setElementAt(smallestIndex, index);
                parts.setElementAt(index, temp);
    }Edited by: SammyP on Nov 27, 2009 11:43 AM

    SammyP wrote:
    I have to write a program that sorts a Vector using the selection sort algorithm...Hmmm.... Your teacher is, in my humble opinion, a bit of a tard.
    1. Vector is basically deprecated in favor of newer implementations of the List interface which where introduced in [the collections framework|http://java.sun.com/docs/books/tutorial/collections/index.html] with Java 1.5 (which became generally available back in May 2004, and went end-of-support Oct 2009). ArrayList is very nearly a "drop in" replacement for Vector, and it is much better designed, and is marginally more efficient, mainly because it is not syncronised, which imposes a small but fundamentally pointless overhead when the collection is not being accessed across multiple threads (as is the case in your program).
    2. Use generics. That "raw" Vector (a list of Objects) should be a genericised List<String> (a list of Strings)... because it's compile-time-type-safe... mind you that definately complicates the definition of your static sort method, but there's an example in the link... Tip: temp should be of type T (not int).
    Note that String implements [Comparable<String>|http://java.sun.com/javase/6/docs/api/java/lang/Comparable.html], so two String's can safely be compared using the compareTo method... In Java the mathematical operators (<, >, &#43;, -, /, &#42;, etc) are only applicable to the primitive types (byte char, int, float, etc)... The Java Gods just chose to muddy the waters (especially for noobs) by "overloading" the &#43; operator for String (and String only) to enable succinct, convenient string-concatenation... which I personally now see as "a little bit of a mistake" on there part.
         private static void  selectionSort(Vector parts)  {
    int index, smallestIndex, minIndex, temp = 0;
    for (index = 0; index < parts.size() - 1; index++) {
    smallestIndex = index;
    for (minIndex = index + 1; minIndex < parts.size(); minIndex++) {
    if (parts.elementAt(minIndex) < parts.elementAt(smallestIndex)) {
    smallestIndex = minIndex;
    parts.setElementAt(temp, smallestIndex);
    parts.setElementAt(smallestIndex, index);
    parts.setElementAt(index, temp);
    }3. ALLWAYS use {curly braces}, even when not strictly necessary for correctness, because (a) they help make your code more readable to humans, and also (b) if you leave them out, you will eventually stuff it up when you insert a line in the expectation that it will be part of the if statement (for example) but you forgot to also add the now mandatory curly-braces... This is far-too-common source of bugs in noob-code. Almost all professionals, nearly allways allways use curly braces, most of the time ;-)
    4. Variable names should be meaningful, except (IMHO) for loop counters... Ergo: I'd rename index plain old i, and minIndex to plain old j
        for ( int i=0; i<list.size()-1; ++i) {
          int wee = i; // wee is the index of the smallest-known-item in list.
          for ( int j=i+1; j<list.size(); ++j ) {Cheers. Keith.
    Edited by: corlettk on 28/11/2009 09:49 ~~ This here fraggin forum markup friggin sucks!

  • Best way of sorting a Vector by member variable

    I have a Vector of objects called Node. Each Node has various member variables, one of which is an integer called cost.
    What would be the best way of sorting this vector in ascending order of cost?
    I tried Bubble Sort but once the Vector starts getting big, it is SO slow.
    Any help much appreciated.
    Thanks,
    Peter

    Declare your Node like this:public class Node ... implements Comparable {
      // your other code here
      public int compareTo(Object o) {
        Node otherNode = (Node)o;
        return this.cost - otherNode.cost;
    }That code provides a "natural ordering" for your Node class. Then to sort your Vector, just do this:Collections.sort(yourVector);I don't know what kind of sort that will do, but no doubt it will be better than your bubble sort.

  • Sorting a Vector by multiple criteria

    Hi,
    I am trying to sort a Vector by multiple criteria. For example, the Vector must first be sorted by category 1, then category 2, etc.
    This is my code so far:
    Vector<Item> temp = new Vector<Item>(items.size());
    Collections.sort(temp, new ByFilename());
    Collections.sort(temp, new BySong());
    Collections.sort(temp, new ByArtist());
         private static class Item
              String CD, track, song, artist, details, filename;
              int row;
              Item(String c, String t, String s, String a, String d, String f, int r)
                   CD = c;
                   track = t;
                   song = s;
                   artist = a;
                   details = d;
                   filename = f;
                   row = r;
         private static class ByFilename implements Comparator<Item>
              public int compare (Item one, Item two)
                   return  one.filename.compareTo(two.filename);
         private static class BySong implements Comparator<Item>
              public int compare (Item one, Item two)
                   return  one.song.compareTo(two.song);
         private static class ByArtist implements Comparator<Item>
              public int compare (Item one, Item two)
                   return  one.artist.compareTo(two.artist);
         }Except this sorts the Vector by Filename, then sorts again from scratch by song, then again from scratch by artist. However, I want it sorted by Filename, with the duplicate Filenames sorted by song, and entries with the same Filename and songs, sorted by artist. I hope this makes sense!!
    Does anyone have any ideas? I tried sorting by filename, finding the duplicates, sorting these in a separate vector and then adding back in, but it didn't work and was too messy. There has to be an easier way... that is much less fiddly.
    Thanks in advance for any help :)

    Here's a demo of using chained comparators.
    import java.util.*;
    public class Item {
        String a, b, c;
        public Item(String a, String b, String c) {
            this.a = a;
            this.b = b;
            this.c = c;
        public String toString() {
            return  a +  b + c;
        public static void main(String[] args) {
            Item[] items = {
                new Item("0","1","1"),
                new Item("1","1","1"),
                new Item("0","1","0"),
                new Item("1","1","0"),
                new Item("0","0","1"),
                new Item("1","0","1"),
                new Item("0","0","0"),
                new Item("1","0","0"),
            Arrays.sort(items, new ByA(new ByB(new ByC(null))));
            System.out.println(Arrays.toString(items));
    class ByA implements Comparator<Item> {
        Comparator<Item> tieBreaker;
        ByA(Comparator<Item> tieBreaker) {
            this.tieBreaker = tieBreaker;
        public int compare (Item one, Item two){
            int result = one.a.compareTo(two.a);
            if (result == 0 && tieBreaker != null) {
                result = tieBreaker.compare(one, two);
            return result;
    class ByB implements Comparator<Item> {
        Comparator<Item> tieBreaker;
        ByB(Comparator<Item> tieBreaker) {
            this.tieBreaker = tieBreaker;
        public int compare (Item one, Item two){
            int result = one.b.compareTo(two.b);
            if (result == 0 && tieBreaker != null) {
                result = tieBreaker.compare(one, two);
            return result;
    class ByC implements Comparator<Item> {
        Comparator<Item> tieBreaker;
        ByC(Comparator<Item> tieBreaker) {
            this.tieBreaker = tieBreaker;
        public int compare (Item one, Item two){
            int result = one.c.compareTo(two.c);
            if (result == 0 && tieBreaker != null) {
                result = tieBreaker.compare(one, two);
            return result;
    }

  • Sorting a vector where each element is a vector

    Hi,
    Sorry for the post but I can't seem to get my head around sorting in Java using Comparator.
    I've a vector where each element is a vector containing strings, integers and doubles and the first element of each vector is a double.
    I need to sort the vector based on this first value of each element which is a vector.
    Hope some can help,
    Thanks in advance,
    Lou

    Here is a generic comparator you can use to sort a List. Vector implements the List interface to you can sort the Vector.
    import java.util.Comparator;
    import java.util.List;
    * A comparator to sort Lists of data based on a column within each List
    public class ListComparator implements Comparator
        private int column;
        private boolean ascending;
        ListComparator(int column, boolean ascending)
            this.column = column;
            this.ascending = ascending;
        public int compare(Object a, Object b)
            List v1 = (List)a;
            List v2 = (List)b;
            Object o1 = v1.get(column);
            Object o2 = v2.get(column);
            // Treat empty strings like nulls
            if (o1 instanceof String && ((String)o1).length() == 0)
                o1 = null;
            if (o2 instanceof String && ((String)o2).length() == 0)
                o2 = null;
            // Sort nulls so they appear last, regardless  of sort order
            if (o1 == null && o2 == null) return 0;
            if (o1 == null) return 1;
            if (o2 == null) return -1;
            //  Compare objects
            if (o1 instanceof Comparable)
                if (ascending)
                    return ((Comparable)o1).compareTo(o2);
                else
                    return ((Comparable)o2).compareTo(o1);
            else  // Compare as a String
                if (ascending)
                    return o1.toString().compareTo(o2.toString());
                else
                     return o2.toString().compareTo(o1.toString());
    }You invoke the sort by using:
    Collections.sort(yourVector, new ListComparator(column, ascending));

  • Need to sort two vectors at the same time! please help!

    I have
    vectorA: 2 4 9 1 7 6 8
    vectorB: two four nine one seven six eight
    i want to sort these two vectors in parallel
    what is the best way?
    i could just do Collection.sort(vectorA) and get
    1 2 4 6 7 8 9
    but i want the vectorB to have a corresponding order
    please help!!
    thanks

    public class Pair implements Comparable {
    private int value;
    private String name;
    public int getValue() {
    return this.value;
    public void setValue(int value) {
    this.value = value;
    public String getName() {
    return this.name;
    public void setName(String name) {
    this.name = name;
    public int compareTo(Object o) {
    Pair that = (Pair) o;
    return this.value - that.value;
    place both in a Collection (vector is a bad choice if you are going to do sorting LinkedList is better) the Collections.sort method will sort
    according to the compareTo method.

  • Sort a vector of objects by one of its attributes

    Hi all!
    I have created this class:
    public class Client {
    private int numero;
    private double tempsEntrada;
    private double tempsServei;
    private double tempsIniciSessio;
    private char tipus;
    * Creates a new instance of Client
    public Client(int num, double temp,double servei, char tip) {
    numero = num;
    arrivalTime = temp;
    serviceTime = servei;
    tipus = tip;
    public char getTipus()
    return tipus;
    public int getNumero()
    return numero;
    public double getTempsEntrada()
    return arrivalTime;
    public double getTempsServei()
    return serviceTime;
    Now I've done a java vector of this object, and I want to sort it by arrivalTime.
    The class comparer looks like this
    public class Comparer implements Comparator {
    public int compare(Object obj1, Object obj2)
    double temps1 = ((Client)obj1).getTempsEntrada();
    double temps2 = ((Client)obj2).getTempsEntrada();
    return (int)(temps1 - temps2);
    now when I do Collections.sort(vector);
    this is the error reported:
    Exception in thread "main" java.lang.ClassCastException: cafevirtual.Client cannot be cast to java.lang.Comparable
    at java.util.Arrays.mergeSort(Arrays.java:1144)
    at java.util.Arrays.mergeSort(Arrays.java:1155)
    at java.util.Arrays.mergeSort(Arrays.java:1155)
    at java.util.Arrays.sort(Arrays.java:1079)
    at java.util.Collections.sort(Collections.java:117)
    at cafevirtual.Main.main(Main.java:76)
    Java Result: 1
    what's wrong?
    thanks!

    Your Client class does not implement Comparable. You have to specify the Comparator to use: Collections.sort(vector, new Comparer());

Maybe you are looking for

  • Premiere CS4 with Media Encoder CS5?

    Hi, When I was given my CS4 suite (production premium) years back, it included Premire Pro.  Then, when I told my boss I needed to upgrade to CS5, he purchased the Web Premium Suite.  This was fine, for the most part, as Illustrator, Flash, and Photo

  • MRP Minimum order qty not recognized

    Hello together! We found out (note 862814 ) that mrp does not manage minimum order quantities right (see below). Version: SAP BUSINESS ONE 2007 A PL 6 Description of requirements: Dear Madams and Sirs, MRP Wizard yields unexpected result. For an item

  • Complex Types & Web Services

    Portal 7 allows you to create portlets from WSDL files. I have a web service that has an interface which returns a org.w3c.dom.Document. The portlet wizard won't generate code from this interface since it uses a "complex type". Is there any way to al

  • Signature creation

    What is the best way to create a signature in Mail that has a graphic file and my address in a specific font? I already have one that is received in many different ways by the recipients and comes back in very strange formats...

  • Use of compounding attributes?

    Hi, can i get what is use of compounding attributes, what scenerio we use this, can i get 1 scenerio. Regards anitha