public void sortIndex ( float input [ ] , int start , int length , int indexes [ ] ) { for ( int i = 0 ; i < length ; i ++ ) indexes [ i ] = i ; for ( int i = 0 ; i < histIndexes . size ; i ++ ) { histIndexes . get ( i ) . reset ( ) ; } for ( int i = 0 ; i < length ; i ++ ) { int indexInput = i + start ; int discretized = ( int ) ( ( input [ indexInput ] - minValue ) / divisor ) ; histIndexes . data [ discretized ] . add ( indexInput ) ; } // over wrist the input data with sorted elements int index = 0 ; for ( int i = 0 ; i < histIndexes . size ; i ++ ) { GrowQueue_I32 matches = histIndexes . get ( i ) ; for ( int j = 0 ; j < matches . size ; j ++ ) { indexes [ index ++ ] = matches . data [ j ] ; } } }
Sort routine which does not modify the input array and instead maintains a list of indexes .