我最近阅读了有关quicksort的文章,并且想知道构建自己的功能以使用quicksort对事物进行排序是否明智,或者它是否效率不高.您认为内置排序功能比自建快速排序功能好吗?
I recently read about quicksort and was wondering whether it would be smart to build my own function to sort things with quicksort or if it would be inefficent. What do you think is the built in sort function better than a selfbuilt quicksort function?
推荐答案来自 php/sort
注意:与大多数PHP排序一样 函数,sort()使用一个 快速排序的实施.
Note: Like most PHP sorting functions, sort() uses an implementation of » Quicksort.
PHP的核心功能将用c而不是PHP来实现,因此它们通常应该比用PHP可以自己编写的任何东西都要快得多.在某些情况下,编写自己的案例会更快,但是我想这是在您有一个非常具体的案例时,您可以为此做自己的特定优化.我认为这不太可能.
The core PHP functions will be implemented in c, rather than PHP, so they should generally be significantly faster than anything you can write yourself in PHP. There will be cases where it is faster to write your own, but I guess these would be when you have a very specific case and you can make your own specific optimisations for that. I think that is unlikely to be the case here.