question: public static int [ ] stableSort ( double [ ] array ) { int [ ] index = new int [ array . length ] ; int [ ] newIndex = new int [ array . length ] ; int [ ] helpIndex ; int numEqual ; array = ( double [ ] ) array . clone ( ) ; for ( int i = 0 ; i < index . length ; i ++ ) { index [ i ] = i ; if ( Double . isNaN ( array [ i ] ) ) { array [ i ] = Double . MAX_VALUE ; } } quickSort ( array , index , 0 , array . length - 1 ) ; int i = 0 ; while ( i < index . length ) { numEqual = 1 ; for ( int j = i + 1 ; ( ( j < index . length ) && Utils . eq ( array [ index [ i ] ] , array [ index [ j ] ] ) ) ; j ++ ) numEqual ++ ; if ( numEqual > 1 ) { helpIndex = new int [ numEqual ] ; for ( int j = 0 ; j < numEqual ; j ++ ) helpIndex [ j ] = i + j ; quickSort ( index , helpIndex , 0 , numEqual - 1 ) ; for ( int j = 0 ; j < numEqual ; j ++ ) newIndex [ i + j ] = index [ helpIndex [ j ] ] ; i += numEqual ; } else { newIndex [ i ] = index [ i ] ; i ++ ; } } return newIndex ; }
target:  Sorts a given array of doubles in ascending order and returns an array of integers with the positions of the elements of the original array in the sorted array. The sort is stable (Equal elements remain in their original order.) Occurrences of Double.NaN are treated as Double.MAX_VALUE