we add the condition i <= sortIndex because we don 't want to traverse  on the sorted part of the queue,  which is the right part.
if ( current <= min_value && i <= sortIndex ) { min_index = i ; min_value = current ; }