Hi Rahul Gupta,
Really, I don't know how you wanted your hash sorted but I guess you would like to sort using "keys" since, your values from your OP are "kind" of sorted, following the numbers on the names like UEH1_system_ip, UEH11_system_ip,.. etc.
The following shows one way of doing it:
use warnings;
use strict;
my %ip_store = (
"11.0.0.1" => "UEH1_system_ip",
"11.0.0.11" => "UEH11_system_ip",
"11.0.0.3" => "UEH25_system_ip",
"11.0.0.25" => "UEH111_system_ip"
);
my @ip_data =
map { $_->[0] }
sort { $a->[1] <=> $b->[1] }
map { /\.([0-9]+)$/; [ $_, $1 ] } keys %ip_store;
print $ip_store{$_}, $/, $_, $/ for @ip_data;
...produces ...
UEH1_system_ip
11.0.0.1
UEH25_system_ip
11.0.0.3
UEH11_system_ip
11.0.0.11
UEH111_system_ip
11.0.0.25
If you tell me, I'll forget.
If you show me, I'll remember.
if you involve me, I'll understand.
--- Author
unknown to me