Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

•Re: Render numeric sequence as array of letters

by merlyn (Sage)
on May 19, 2003 at 21:19 UTC ( [id://259296]=note: print w/replies, xml ) Need Help??


in reply to Render numeric sequence as array of letters

It looks like you want ordered rank.
my @original = qw(5, 100, 2, 8, 40); my @sorted_indicies = sort { $original[$a] <=> $original[$b] } 0..$#or +iginal; my @rank; @rank[@sorted_indicies] = 0..$#sorted_indicies; my @letters = map { chr(ord('A') + $_) } @rank; print "@letters\n";
That gives me "B E A C D", just like you want.

-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://259296]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (4)
As of 2024-04-20 02:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found