Newsgroups: perl.perl6.language
From: fibon...@babylonia.flatirons.org (Luke Palmer)
Date: Wed, 11 Feb 2004 20:11:34 -0700
Local: Wed, Feb 11 2004 10:11 pm
Subject: The Sort Problem
I've been thinking about this problem which comes up in my code a lot:
@sorted = sort { $^a.foo('bar').compute <=> $^b.foo('bar').compute } Often the expressions on each side are even longer than that. But one I can see a couple less-than-desirable ways around this redundancy: @sorted = sort { infix:<=>( *($^a, $^b)».foo('bar').compute ) } Which doesn't work if .compute returns a list... not to mention its multi sub sort (&block($) = { $_ } : *@data) { @sorted = sort { .foo('bar').compute } @unsorted; Which has the disadvantage of forcing you to use C<cmp> and forcing an Any other ideas? Is a more general solution necessary? Luke You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
| ||||||||||||||