jeudi 16 août 2018

Ruby sorting two arrays of array to align the common element in both arrays

I reached at the following step while working on some log processing task

process_start_array = [["process_1", "Start", "2018-06-15", "13:00:50,560"], ["process_2", "Start", "2018-06-15", "13:00:50,762"], ["process_3", "Start", "2018-06-15", "13:00:50,827"], ["process_4", "Start", "2018-06-15", "13:00:50,154"]]

and

process_end_array = [["process_4", "End", "2018-06-15", "13:00:50,560"], ["process_1", "End", "2018-06-15", "13:00:50,762"], ["process_2", "End", "2018-06-15", "13:00:50,827"], ["process_3", "End", "2018-06-15", "13:00:51,484"]]

As you can see that some process take long and ends later while some process do not take long and finish faster.

In order to calculate the process execution time and perform ruby date time subtraction, I would like to sort the process_end_array based on the process_start_array so that that start and end events of the same process are aligned. How can I achieve that?

Aucun commentaire:

Enregistrer un commentaire