There is a hash of items, say indexed by int keys (1, 2, 3, 6,8,...). The hash is tied dbm hash. Given an integer, I'd like to find that, either the integer is a key, or if it is not, what is the closest integer (but less than it) that is a key. For instance, 3 is a key in the hash, the closest key to 4 is 3. The closest key to 7 is 6. How can I solve the problem? Thanks a lot.