Java Vector Sort sortInsert(Vector v, Object obj)

Here you can find the source of sortInsert(Vector v, Object obj)

Description

sort Insert

License

Open Source License

Declaration

public static void sortInsert(Vector v, Object obj) 

Method Source Code


//package com.java2s;
import java.util.*;

public class Main {
    public static void sortInsert(Vector v, Object obj) {
        Enumeration e = v.elements();
        for (int i = 0; i < v.size(); i++) {
            Object cur = v.elementAt(i);
            if (obj.toString().compareTo(cur.toString()) < 0) {
                v.insertElementAt(obj, i);
                return;
            }//w  w w  . j av a  2  s . c om
        }
        v.addElement(obj);
    }
}

Related

  1. sort(Vector unsorted, int sortKeyPos, int maxVal)
  2. sortIntegerVector(Vector toSort)