From: Panagiotis Atmatzidis Date: 2012-07-09T05:52:26+09:00 Subject: Re: Troubled while trying to create list from hash Hello, On 8 Ιουλ 2012, at 11:35 , sto.mar@web.de wrote: > Am 08.07.2012 04:14, schrieb Panagiotis Atmatzidis: >> I have a hash with IP addresses and numbers. Each number represents the number that the IP address is found in a log. > > You should provide more information about this hash > (are these *line* numbers?) and provide an example. puts @data_table returns lines like this: "2012-05-21 09:51:21 [ssh-iptables] 222.177.23.129 CN China" So the ip is referred in the source code as "[entry.split(' ')[3]]" ... which returns the 4th parameter (if you start counting by 1 the 3rd if you count in ruby way). > >> I want to create a list, which contains the IP address (or addresses) of the most frequently found IP(s). >> >> Here is my approach however doesn't work as it should: http://codepad.org/CNaVyJ1H > > What does @data_table look like??? > What should your method do and what does not work? @data_table is an Array class, containing multiple strings as the one above. > (Why do you need the 'any' part, > isn't 'sorted' already the list you are looking for?) There are some "duplicate IP's" which I want to enumerate. There are two IP's that appear 7 times. I want o add these into a secondary list in order to display them later on in another function. > > > -- > > > Panagiotis Atmatzidis ----------------------------- Pharmacy Student at VFU email4lists: ml@convalesco.org More info: http://about.me/atmosx The wise man said: "Never argue with an idiot, he brings you down to his level and beat you with experience."