I have a list of lines read from a file. I need to sort the list by time stamp. I have parsed out the time stamp using regular expressions and place them into a separate list. The indices of the two lists will match. Once I sort the list of time stamps, I can get the order of indices.
Is there a way to apply the same order of indices to the original list of lines? The result should be the sorted list of original lines.
Example:
listofLines = ['log opened 16-Feb-2010 06:37:56 UTC',
'06:37:58 Custom parameters are in use',
'log closed 16-Feb-2010 05:26:47 UTC']
listofTimes = ['06:37:56', '06:37:58', '05:26:47']
sortedIndex = [2,0,1]