Iterator i = collection.iterator(); Object[]  array = new Object[collection.size()]; Object[]  clone = new Object[collection.size()]; int index = 0; Object obj; while (i.hasNext()) { obj = i.next(); array[index] = obj; clone[index] = obj; index++; } shuttlesort(clone, array, 0, array.length); results = new ArrayList(); for (int j = 0; j < array.length; j++) results.add(array[j]); return results;
this.collection = collection; return sort();
    public List sort()    {        if (collection == null)             throw new NullPointerException("No collection to sort.");        Iterator i = collection.iterator();        Object[]  array = new Object[collection.size()];        Object[]  clone = new Object[collection.size()];        int index = 0;        Object obj;        while (i.hasNext()) {            obj = i.next();            array[index] = obj;            clone[index] = obj;            index++;        }        shuttlesort(clone, array, 0, array.length);        results = new ArrayList();        for (int j = 0; j < array.length; j++)              results.add(array[j]);        return results;    }