gov.sandia.cognition.util
Class ArrayIndexSorter
java.lang.Object
gov.sandia.cognition.util.ArrayIndexSorter
@CodeReviews(reviews={@CodeReview(reviewer="Kevin R. Dixon",date="2008-10-02",changesNeeded=false,comments="Looks fine."),@CodeReview(reviewer="Kevin R. Dixon",date="2006-07-18",changesNeeded=false,comments={"Added a couple comments.","Otherwise, looks fine."})})
public class ArrayIndexSorter
- extends Object
Returns the indices of the array sorted in ascending or descending order
- Since:
- 1.0
- Author:
- Kevin R. Dixon
Method Summary |
static int[] |
sortArrayAscending(double[] valuesToSort)
Returns the indices of the array sorted in ascending order |
static int[] |
sortArrayDescending(double[] valuesToSort)
Returns the indices of the array sorted in ascending order. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ArrayIndexSorter
public ArrayIndexSorter()
sortArrayAscending
public static int[] sortArrayAscending(double[] valuesToSort)
- Returns the indices of the array sorted in ascending order
- Parameters:
valuesToSort
- values that should be sorted in ascending order,
via a call to Arrays.sort(), does not change values of "valuesToSort"
- Returns:
- indices of the ascending-ordered valuesToSort, so that
index[0] is the smallest value, and index[index.length-1] is the biggest
sortArrayDescending
public static int[] sortArrayDescending(double[] valuesToSort)
- Returns the indices of the array sorted in ascending order. This is
accomplished by a call to sortArrayAscending and then swapping the
result. As such, this will always be the slower of the two calls.
- Parameters:
valuesToSort
- values that should be sorted in descending order
- Returns:
- indices of the descending-ordered valuesToSort, so that
index[0] is the biggest value, and index[index.length-1] is the smallest