Tag: Sort

Insertion sort in Python

Introduction Insertion sort is a simple in place (i.e no need for an auxiliary memory) sorting algorithm. It is an efficient algorithm for small data sets, specially for lists that are partially sorted. For more information about how sorting works, you may refer to the following article For more in depth information about insertion sort

Parse Log File – Unix

Problem You have a log file on UNIX operating system. Each line in the log file contains an IP address in the 10th column where columns (or fields) are separated by a space. How can you print the unique IP addresses in the log file using UNIX shell Solution This is the same problem as

Perl Sort Hash by Value

Problem Given a log file similar to Linux syslog format as in the following example: Jan 4 03:15:01 pla kernel:pla: Some error message Write a Perl script to print the top 5 most repeated error messages. Solution Read the file line by line then split each line using ":" as separator then use the error