>The order of sorting is O(nlgn) (I think perl uses quicksort). 
>Finding the maximum or minimum in a list can be done
>in O(n) time. This being the case sorting the files by age
>is not the best solution.


Just to keep the records straight, 

@sortedFiles = sort{ -M $a <=> -M $b} @files;

is a very costly operation because of Sudharshan's statement. That is the
sort algorithm then uses -M operator nlog(n) times for a list with n
elements. And for a OS system call of -M that many times is costly indeed.

However the good thing about Schwartzian Algorithm is that the -x operator
is performed only once! The results are cached, and the sort algorithm never
accesses OS for determining the -x values.

Thanks,
-- Rex


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to