>>>>> "DD" == Darren Duncan <[EMAIL PROTECTED]> writes:
DD> At 9:30 AM +0000 12/17/05, Luke Palmer wrote: >> >> You're actually saying that undef either compares less than or greater >> than all other objects, which contradicts your earlier point. I'd say >> it just fails. DD> At the time I wrote this, I had been thinking that having a list of DD> array values where some were undefined was still not unreasonable to DD> be sorted. And in that case, since undef's can't sort by normal means DD> (value comparisons don't work on them), we have to do something with DD> them so the sorted array has all the elements of the original, hence DD> group them at one end. DD> However, perhaps it does make better sense for wider consistency that DD> a sort needs to have an explicit handler that says what to do with DD> undefs, or otherwise the sort fails. sorting in p6 is not at all like in p5. instead of coding up an explicit comparison code block and duplicating all the key access code (for $a and $b), you will specify how to extract/generate each key for a given record. this new syntax was posted by damian (who else) and it is very similar to the api in my p5 module sort::maker (we did discuss this api). i don't know if any A/E/S doc covers it but it is definitely in the archives. so you could easily handle undefs by converting them to the sort value you want. using // it would be trivial to do (assume an array ref record is passed in $_ and the key is the second element). these are code blocks to extract and generate a key. { $_->[1] } # sort undef as 0 with lotsa warnings { $_->[1] // 0 } # sort undef as 0 with no warnings { $_->[1] // -Inf } # sort undef to bottom { $_->[1] // Inf } # sort undef to top <perl_mad_hatt^H^Hcker>damian take note!</perl_mad_hatt^H^Hcker> i dunno if +/- Inf are available/useable for sorting. it would be a useful feature regardless of how undef behaves. sometimes you need to force certain values to the top or bottom of sorts and this would make it very easy to do. so again, i am on the side of leaving undef's default behavior alone and using a stricture to get your desirec behavior. uri -- Uri Guttman ------ [EMAIL PROTECTED] -------- http://www.stemsystems.com --Perl Consulting, Stem Development, Systems Architecture, Design and Coding- Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org