Add min/max/min_by/max_by optional argument support

Per issue #2099 - adds support for an optional argument which indicates
that the method should return an array of values corresponding to the top
n values. This is currently implemented as sort.first(n) or sort.last(n).reverse
and should be refactored to something that is O(n) memory rather than O(elems).
Return empty arrays when the optional arg is passed but the range is empty.
Merge pull request #2101 from cheald/add_min_max_arg

Add min/max/min_by/max_by optional argument support