Class: Hash

Inherits:
Object
  • Object
show all
Defined in:
lib/log2counter/core_ext/sort_by_ip_or_host.rb

Instance Method Summary collapse

Instance Method Details

#sort_by_ip_or_hostObject

Sort IP addresses numerically by net part, and host names just as usual.



35
36
37
38
39
40
41
# File 'lib/log2counter/core_ext/sort_by_ip_or_host.rb', line 35

def sort_by_ip_or_host
  sort_by { |key, _|
    key ? key.split('.').map { |part|
      part =~ /\A\d+\z/ ? part.to_i : part
    } : []
  }
end