uncertain how you were getting the data, but here is one shot: my @MyData = qw(4.0.0.10 4.0.0.9 4.0.1.0); foreach my $MyKey(sort {$b->[1] <=> $a->[1] || $b->[2] <=> $a->[2] || $b->[3] <=> $a->[3] || $b->[4] <=> $a->[4] } map{[ $_ , split(/\./, $_) ]} @MyData) { printf "%10s\n", $MyKey->[0]; }
This will have the first entry through being the highest version. Assumes numeric only input. Wags ;) -----Original Message----- From: Christopher Hahn [mailto:[EMAIL PROTECTED]] Sent: Monday, December 02, 2002 13:33 To: Perl win32 email list ([EMAIL PROTECTED]) Subject: sorting version numbers Hello, I am wondering what the perl-best-practice approach to sorting version numbers might be. I am looking at strings like "4.0.0.10", "4.0.0.9", "4.0.1.0", etc and I need to determine the "highest", in this case 4.0.1.0. Previous experience suggests splitting each of these into a list of numbers and then comparing two "versions" by comparing each component number until a winner is found. Is there an existing (semi-built-in?) solution to this problem? TIA for any pointers? Christopher -- There are only 10 types of people in the world: Those who understand binary and those who don't. _______________________________________________ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs ********************************************************** This message contains information that is confidential and proprietary to FedEx Freight or its affiliates. It is intended only for the recipient named and for the express purpose(s) described therein. Any other use is prohibited. **************************************************************** _______________________________________________ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs