用php构建quicksort [英] Building quicksort with php

查看:49
本文介绍了用php构建quicksort的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近阅读了有关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?

推荐答案

来自 http://php.net/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.

这篇关于用php构建quicksort的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆