Calling sort without a comparison function is nearly always the wrong thing to do. However, I can think of two exceptions to this.
The first exception is when you have no other goal but to iterate in an order that is merely repeatable, even if that order should happen to completely arbitrary.
Do you have any statistics -- real or made up -- about the percentage of sorts performed by programs in Perl (or any or all programming languages) that do not fit the criteria of your first "exception"?
Because after ~30 years of programming in which my gut feel is that 90% or there about of my programs have included a sort for some purpose or another, I can remember just 2 occasions when language dictionary ordering was a goal. One was an internal phone directory. The other was the 6 million records of West African Examination Council University entrance examination results.
At ~300 people, the first was sufficiently short that whether 'Mac...' came before, after or adjacent to 'Mc...' was irrelevant.
In the latter, which encompasses names from 5 countries: Ghana, Liberia, Nigeria, Sierra Leone, and the Gambia, with all their combined mixes of ethnic, religious, tribal and imperial languages, cultures and backgrounds, meant that it was impossible to get them to agree on a single correct collation. Hence, the reports produced for each country, and even different areas within the same country, all had to be ordered differently according to a custom collation.
That was a good many years ago, but I guarantee that there isn't anything on CPAN that would have handled any single one of the dozen or so collation sequences required.
My personal gut-feel assessment is that for 95% (and probably more) uses of sort in programs, the actual collation ordering used is immaterial. What's yours?
In reply to Re^2: best sort
by BrowserUk
in thread best sort
by ag4ve
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |