Generalized the extrema-finding functions for Hashtbl.