corrected sorting. Added locality, limit, and pretty print options