Comparing the Performance of Two Sorting Methods

Поделиться
HTML-код
  • Опубликовано: 7 фев 2025
  • I had an idea about how to sort numbers where each number in an unsorted array was an actual index into another array. I have a loop that increments the value at an index indicating that the number that index represents is present 1 or more times.
    I can't really do a good job explaining the gist of my sorting method simply for the moment. I did a few tests to see if arrays were getting sorted correctly and they were as far as my testing could tell.
    My sorting method consumes quite a bit of memory, since I am creating an array element for every possible value up to a certain maximum.
    I was surprised to see that my own custom algorithm for sorting outperformed the PHP library sorting routine in terms of time by about a factor of 5. That's not really a huge difference, and when you consider how wasteful my method for sorting is with memory, I can't say with honesty that my sorting routine is any better than anyone else's.

Комментарии •