Java Array Sort sortNames(String[] names)

Here you can find the source of sortNames(String[] names)

Description

sort Names

License

Apache License

Declaration

public static void sortNames(String[] names) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.util.Arrays;

public class Main {
    public static void sortNames(String[] names) {

        System.out.print("Names: ");
        System.out.println(Arrays.toString(names));

        String[] sortedNames = Arrays.copyOf(names, names.length);

        System.out.print("Sorted names:");

        Arrays.sort(sortedNames);
        System.out.println(Arrays.toString(sortedNames));

        System.out.println("The initial names array was sorted:" + Arrays.equals(sortedNames, names));

        System.out.println("The new index of \"Brad Pitt\":" + Arrays.binarySearch(sortedNames, "Brad Pitt"));

    }//from   ww w.  ja  va  2  s.c om
}

Related

  1. sortKeyValuePairs(long[] keys, double[] values, int startInd, int endInd)
  2. sortLeftRightAndCenter(double[] array, int[] index, int l, int r)
  3. sortMatrixRows(A[] matrix, Comparator comparator)
  4. sortMinMaxToMax(double[] min, double[] max)
  5. sortMinToMax(double[] v)
  6. sortNames(String[] names)
  7. sortNames(String[] names)
  8. sortNames(String[] names)
  9. sortNullElements(Object[] array)