I want to sort files by modification time in ascending and descending order.
According to this answer It seems that the best way is to achieve a definition of the sort callback function and use usort / uasort.
However, due to the nature of my application, I will most likely come across some worst-case scenarios for some sorting algorithms (for example, an almost inverse ordered input sequence).
Since each comparison uses two file system accesses that are partially associated with network drives, the number of comparisons is critical and should be kept to a minimum. Other types of iterations may be more.
So what sorting algorithms use the PHP array sorting functions? Quicksort? Multisort? Is there any way to configure this?
Should I shuffle the array before sorting?
Or do I need to write my own implementation?
Do you know some good libraries that provide sorting functions with custom algorithms?
What algorithm or methods to solve this problem of minimizing comparisons would you recommend?
sorting algorithm php
The surrican
source share