Java Array Sort sortAccording(float[] ary, Integer[] sortOrder)

Here you can find the source of sortAccording(float[] ary, Integer[] sortOrder)

Description

Create a new sorted array according to given sort order

License

Apache License

Declaration

public static float[] sortAccording(float[] ary, Integer[] sortOrder) 

Method Source Code

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

public class Main {
    /** Create a new sorted array according to given sort order */
    public static float[] sortAccording(float[] ary, Integer[] sortOrder) {
        float[] res = new float[ary.length];
        for (int i = 0; i < ary.length; i++)
            res[i] = ary[sortOrder[i]];/*from  www  . ja v a 2 s .  c o  m*/
        return res;
    }

    public static String[] sortAccording(String[] ary, Integer[] sortOrder) {
        String[] res = new String[ary.length];
        for (int i = 0; i < ary.length; i++)
            res[i] = ary[sortOrder[i]];
        return res;
    }

    public static int[] sortAccording(int[] ary, Integer[] sortOrder) {
        int[] res = new int[ary.length];
        for (int i = 0; i < ary.length; i++)
            res[i] = ary[sortOrder[i]];
        return res;
    }
}

Related

  1. sort2(double[] arr, double[] brr)
  2. sort3(String[] a, int x, int y, int z)
  3. sort3(String[] arr, float[] brr)
  4. sort5(Long[] data)
  5. sortableBytesToInt(byte[] encoded, int offset)
  6. sortAccording2(int[] ary, Integer[] sortOrder)
  7. sortAlleleCount(int[] count)
  8. SortAndConcatenateStringArray(String StrArray[], String Separator)
  9. sortArray(double[] array)