sort the samples by index , if not already . concode_field_sep Sample[] recycledSamples concode_elem_sep int recycledSampleCount concode_elem_sep int SORT_ORDER_BY_INDEX concode_elem_sep int MAX_RECYCLED_SAMPLES concode_elem_sep int index concode_elem_sep int weight concode_elem_sep Comparator<Sample> VALUE_COMPARATOR concode_elem_sep int maxWeight concode_elem_sep int SORT_ORDER_NONE concode_elem_sep ArrayList<Sample> samples concode_elem_sep Comparator<Sample> INDEX_COMPARATOR concode_elem_sep int nextSampleIndex concode_elem_sep int totalWeight concode_elem_sep float value concode_elem_sep int SORT_ORDER_BY_VALUE concode_elem_sep int currentSortOrder concode_field_sep int compare concode_elem_sep int compare concode_elem_sep void ensureSortedByValue concode_elem_sep void addSample concode_elem_sep float getPercentile
void function ( ) { if ( currentSortOrder != SORT_ORDER_BY_INDEX ) { Collections . sort ( samples , INDEX_COMPARATOR ) ; currentSortOrder = SORT_ORDER_BY_INDEX ; } }