Posted By:
Stephen_McConnell
Posted On:
Thursday, July 24, 2003 05:10 AM
I'm trying to understand
why?
The data structure you are using mixes the metaphors. You should have one vector for the Strings and one for the numbers, then place those two vectors in the parent container.
If you are set on using Vectors, here's a better way to do this.
Vector outerVector = new Vector();
Vector innerVector1 = new Vector();
Vector innerVector2 = new Vector();
innerVector1.add("Good");
innerVector1.add("Bad");
innerVector1.add("Ugly");
innerVector2.add(new Integer(10));
innerVector2.add(new Integer(50));
innerVector2.add(new Integer(100));
outerVector.add(innerVector1);
outerVector.add(innerVector2);
Now you can use the collections sort to sort the second and first vectors any way you want.
The movement of innerVector1 is not tied to the movement of innerVector2.
You might want to get a book on Data Structures in Java, however. Then, you would see about 100 better ways to do this.
Stephen McConnell