com.jamonapi.utils.ArraySorter Maven / Gradle / Ivy
package com.jamonapi.utils;
import java.util.Arrays;
/**
* ArraySorter is used to sort 2 dimensional arrays of objects by one of the columns in the array. Right now this class
* sorts only for the monitor report, but could be made more generic.
*
*/
class ArraySorter {
public ArraySorter(Object[][] array, int sortCol, String sortOrder) {
this.array=array;
this.sortCol=sortCol;
this.sortOrder=sortOrder;
}
private Object[][] array;
private int sortCol;
private String sortOrder;
private int getRows() {
return array.length;
}
private int getCols() {
return array[0].length;
}
private Object[] getArrayToSort() {
Object[] arrayToSort=new Object[getRows()];
for (int i=0; i