Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Check if sort has changed order

by johngg (Abbot)
on May 10, 2013 at 15:47 UTC ( #1032974=note: print w/ replies, xml ) Need Help??


in reply to Check if sort has changed order

Use Digest::MD5 to see if something has changed. The md5_hex() function will concatenate its arguments then operate on the concatenated string.

$ perl -Mstrict -Mwarnings -MDigest::MD5=md5_hex -E ' my @arr1 = qw{ tiger bear shark lion }; say md5_hex( @arr1 ); say md5_hex( sort @arr1 );' 4c15f2e87b25ac112649edfd426d5082 27f304e4e99072211806f923bbb39705 $ perl -Mstrict -Mwarnings -MDigest::MD5=md5_hex -E ' > my @arr1 = qw{ antelope cow deer sheep }; > say md5_hex( @arr1 ); > say md5_hex( sort @arr1 );' 1f0210f9b5d6dababea92da7018905da 1f0210f9b5d6dababea92da7018905da $

I hope this is of interest.

Cheers,

JohnGG


Comment on Re: Check if sort has changed order
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (7)
As of 2014-12-25 08:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (159 votes), past polls