Java Array Sort collectionToSortedArray(Collection objects)

Here you can find the source of collectionToSortedArray(Collection objects)

Description

collection To Sorted Array

License

Open Source License

Declaration

public static Object[] collectionToSortedArray(Collection<? extends Object> objects) 

Method Source Code

//package com.java2s;
/**/* w w w  .  j  av  a 2 s . c  om*/
 * This file is licensed under the University of Illinois/NCSA Open Source License. See LICENSE.TXT for details.
 */

import java.util.Arrays;
import java.util.Collection;
import java.util.Comparator;

public class Main {
    public static Object[] collectionToSortedArray(Collection<? extends Object> objects) {
        Object[] sortedArray = objects.toArray(new Object[] {});
        Arrays.sort(sortedArray, new Comparator<Object>() {

            @Override
            public int compare(Object o1, Object o2) {
                return o1.toString().compareTo(o2.toString());
            }

        });
        return sortedArray;
    }
}

Related

  1. addSorted(int[] array, int[] newValues)
  2. addSortedUnique(T[] array, T object, int start)
  3. addToSortedIntArray(int[] a, int value)
  4. bitReversalSort(final short[] real)
  5. calculatePValueForDataPoint(double dataPoint, double[] sortedNullHypothesisSample)
  6. copyAndSort(String[] input)
  7. copyAndSort(T[] builtinFunctions)
  8. copySortArray(String[] values)
  9. countingSort(int[] a, int low, int high)