Return the maximal element,sorts in ascending / descending order

Return the maximal element in a portion of array of integers starting at given index,sorts an array in ascending / descending order.