最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

用php构建quicksort

SEO心得admin126浏览0评论
本文介绍了用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?

推荐答案

来自 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.

发布评论

评论列表(0)

  1. 暂无评论