[4.2] Database Collection : move max and min functions

Move min and max functions so that we can use them in a "normal" Support\Collection
Well the key is not necessary an integer, it can also be a string. The tests fails for min().
As most of the job is already done with `keyBy`, I've used it instead.