I am running below code to sort strings and not getting the expected results.
Code:
use warnings;
use strict;
my @strArray= ("64.0.71","68.0.71","62.0.1","62.0.2","62.0.11");
my @sortedStrArray = sort { $a cmp $b } @strArray;
foreach my $element (@sortedStrArray ) {
print "\n$element";
}
Result:
62.0.1
62.0.11 <--- these two
62.0.2 <---
64.0.71
68.0.71
Expected Result:
62.0.1
62.0.2 <---
62.0.11 <---
64.0.71
68.0.71