Similar to the maxval function already in place.
I guess this can share more code with Maxval.
Has this been extended to multi-dimensional arrays like SUM? If so, add a testcase for that as well.
LGTM modulo Kiran's remarks.