Solved

Sorting the vectors

Posted on 2003-11-23
3
249 Views
Last Modified: 2010-03-31
Hi

How can I sort the vectors?

Thanks and Regards,
0
Comment
Question by:lakkiprasanna
  • 2
3 Comments
 
LVL 14

Expert Comment

by:sudhakar_koundinya
ID: 9808677
read answers from my previous link (I have given answer there already)

http://www.experts-exchange.com/Programming/Programming_Languages/Java/Q_20095494.html

0
 
LVL 14

Accepted Solution

by:
sudhakar_koundinya earned 25 total points
ID: 9808686

// simple bubble sort.
for (int j=myDateVector.size()-1;j>=1;j--) {
    for (int i=0;i<j;i++) {
         Date d1=(Date) myDateVector.elementAt(i);
         Date d2=(Date) myDateVector.elementAt(i+1);
         
         if (d2.getTime()<d1.getTime()) {
              myDateVector.setElementAt(d2, i);
              myDateVector.setElementAt(d1, i+1);
         }
    } from http://www.experts-exchange.com/Programming/Programming_Languages/Java/Q_20095494.html
0
 

Author Comment

by:lakkiprasanna
ID: 9808700
actually iam expecting for date sorter only

thanks sudhakar for giving other link also
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

792 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question