jAudioFeatureExtractor.GeneralTools
Class Sorter

java.lang.Object
  extended by jAudioFeatureExtractor.GeneralTools.Sorter

public class Sorter
extends java.lang.Object

A holder class for static methods relating to sorting.

Author:
Cory McKay
See Also:
Collator

Constructor Summary
Sorter()
           
 
Method Summary
static int[] getDoubleArraySortKey(double[] to_sort)
          Takes in an array of doubles and returns an array holding the rankings from lowest (0) to highest (to_sort -1) of each entry from lowest to highest.
static double[] sortDoubleArray(double[] to_sort)
          Takes in an array of doubles and returns a copy of the array sorted from lowest to highest.
static java.lang.String[][] sortTable(java.lang.String[][] original_table, int column_to_sort_by, int[] sorted_ordering)
          Takes a two dimensional String array representing a table (column indice first, then row indice) and returns a copy of the table sorted by the data in the given column indice.
static javax.swing.tree.DefaultMutableTreeNode sortTree(javax.swing.tree.DefaultMutableTreeNode root_unsorted_tree)
          Takes the tree with the given root and reorders it so that all siblings are sorted alphebetically.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Sorter

public Sorter()
Method Detail

sortTree

public static javax.swing.tree.DefaultMutableTreeNode sortTree(javax.swing.tree.DefaultMutableTreeNode root_unsorted_tree)
Takes the tree with the given root and reorders it so that all siblings are sorted alphebetically. Recurses through the children so that each level is sorted alphabetically. Returns the root of the new sorted tree.

Parameters:
root_unsorted_tree - The root of the tree to be sorted.
Returns:
A copy of the tree that has been sorted.
See Also:
Collator, DefaultMutableTreeNode

sortTable

public static java.lang.String[][] sortTable(java.lang.String[][] original_table,
                                             int column_to_sort_by,
                                             int[] sorted_ordering)
Takes a two dimensional String array representing a table (column indice first, then row indice) and returns a copy of the table sorted by the data in the given column indice.

The sorted_ordering array is filled to reflect the positions that the old rows were assigned to. This array should have the same size as the number of rows of the original_table parameter. The original values of the sorted_ordering array are irrelevant.

Parameters:
original_table - The table to be sorted.
column_to_sort_by - The column to base the sort on.
sorted_ordering - The number position assigned to each row after sorting.
Returns:
A copy of the table that has been sorted.
See Also:
Collator

sortDoubleArray

public static double[] sortDoubleArray(double[] to_sort)
Takes in an array of doubles and returns a copy of the array sorted from lowest to highest. The orignal array is not altered.

Parameters:
to_sort - The data that is to be sorted.
Returns:
A copy of the array sorted from lowest to highest.

getDoubleArraySortKey

public static int[] getDoubleArraySortKey(double[] to_sort)
Takes in an array of doubles and returns an array holding the rankings from lowest (0) to highest (to_sort -1) of each entry from lowest to highest. The orignal array is not altered.

Parameters:
to_sort - The data that is to be sorted.
Returns:
The rankings of to_sort.