add max, min and sortBy functions and tests