IP-Adressen numerisch sortieren

aus PUG, der Penguin User Group
Wechseln zu: Navigation, Suche

In Perl:

my @sortedips = sort {
  (unpack"N",(pack"CCCC",(split/\./,$a))) <=>
  (unpack"N",(pack"CCCC",(split/\./,$b)))
} @unsortedips;