¿How to find bounding box of an object?

I tried to implement some code to find the bounding box of a given object, but doesnt seems to work. How can I find the higher vertex and the lower vertex in the list of vertices?

This is a very simple task.Loop throug all vertices and take the highest x-value,the highest y-value and the highest z-value as the coordinates of the max vertex…Same thing for the min vertex only difference:Take the lowest values in each direction…