Given an array of integers, return the first and last elements of the original array in sorted order. Return the elements using the reference parameters smaller and larger.