arbitrary sorting...

Kari Chisholm karic at
Mon Jul 15 00:40:31 CDT 2002

So, here's my weekend stumper:

I've got an array:

  @foo = qw/apple porsche ferrari wilma barney banana/;

I want to sort it, but I don't want to sort it alphabetically or in any
other predictable way.  Instead, I've got an arbitrary best order.   Using
my example, let's say that I've got 50 items in my preferred order (@bar)
such that the fruit are grouped first, then cars, then flintstones.

What I want is to compare @foo to @bar such that I'm able to reorder @foo
into: apple banana porsche ferrari wilma barney.

Does that make any sense?  Am I missing something obvious?




More information about the Pdx-pm-list mailing list