Some more specifics: The DB_File approach looked easier (though I only looked briefly). You want to create a databse in DB_BTREE format with a comparison function that does a numeric compare rather than a string compare. You can then use the R_CURSOR flag the seq() method to get what you want.