Queue elements after sortIndex are already sorted . This function returns index of minimum element from front to sortIndex
public static int minIndex ( Queue < Integer > list , int sortIndex ) { int min_index = - 1 ; int min_value = Integer . MAX_VALUE ; int s = list . size ( ) ; for ( int i = 0 ; i < s ; i ++ ) { int current = list . peek ( ) ;