in reply to best sort

If you have, say, "millions of records," and need to match on individual keys, perform multiple disk-based(!) sorts and sequentially compare. If you need to compare all the keys to each other, bite the bullet and extract the keys into a flat file, then sort that. Before you pooh-pooh the idea and insist that "memory's faster," realize "memory's a disk file" because it's "virtual." When the amount of memory consumed grows large, it's not efficient anymore. The total amount of time system resources consumed by your program while it's running should not be dependent upon the data size nor the statistical key-distribution.