![]() |
|
P is for Practical | |
PerlMonks |
comment on |
( #3333=superdoc: print w/replies, xml ) | Need Help?? |
> if I have an array with numbers and strings it will implicitly decide based on the type of $a and $b which comparison to apply?
It will decide for you if you don't explicitly direct it to do otherwise. By default, given a number and a string to compare, it will coerce the number to a string. But if both elements being compared are numbers it will compare them numerically. If you want to sort all numbers as strings, you must say so, eg by passing `~*` as the comparator. > I'm not sure if \sorting by codepoint is\ sufficient to handle different standards. E.g. the telephone book in Germany has another sorting than the dictionaries. Use https://docs.raku.org/routine/collate instead of `sort`. In reply to Re^5: Spoiled by Perl (sorting sugar)
by raiph
|
|