refactor sorted_db into it's own package