f



Sorting algorithm(s) used by PHP's sort function

Does anyone know what sorting algorithm(s) -- quicksort, mergesort,
radix sort, etc. -- does PHP use internally in its sort function?
0
skashyap (1)
7/25/2003 1:33:09 AM
comp.lang.php 32646 articles. 0 followers. Post Follow

1 Replies
817 Views

Similar Articles

[PageSpeed] 46

"Shaunak Kashyap" <skashyap@intertechmedia.com> wrote in message
news:67746bb.0307241733.63a5649f@posting.google.com...
> Does anyone know what sorting algorithm(s) -- quicksort, mergesort,
> radix sort, etc. -- does PHP use internally in its sort function?

There's a lot of sorting algorithms used by PHP.  It looks like the primary
array sorting method is quicksort.  I also found some use of mergesort.
Looking at the source, I found this:

<builddirectory>/ext/standard/array.c

This sets up the "hooks" for most of the array functions for use in Zend.

It looks like all of the sort methods rely on a sort_type == zend_qsort.
Doing a quick search for this in the rest of the source, returns this:

<builddirectory>/Zend/zend_qsort.c

If you look at this file, you can see the good ol' quick sort algorithm in
action.  If you prefer a different algorithm, I'm sure you could replace the
quicksort algorithm, recompile PHP, and whammo!

If you're interested in developing extensions to PHP, the API is pretty well
documented in the manual and in "Programming PHP" by Rasmus Lerdorf.  I wish
I had the time to tinker with PHP at this level.

Take care,
Zac


0
news210 (43)
7/25/2003 2:53:47 AM
Reply:

Similar Artilces:

How to use a class's member function in STL's algorithm?
We know that alomost every algorithm function, such as for_each, find_if, use funcional as well as function pointer. But when I want to use another class's member function, how could I do? See example: class TestPrint { public: TestPrint( int i ) { start_num = i; } void print( int i ) { cout << endl<< "| " << i + start_num << " |" << endl; } private: int start_num; }; int main() { TestPrint* pTest = new TestPrint( 8 ); int a[10] = {0, 1, 2, 3...

It's not C# we have to worry about
Tiobe publishes a monthly ranking of the popularity of programming platforms. It's based on google, so it has to be taken with some grain of salt. Java has been number one since a while now after eclipsing C++, but there are some languages that are rapidly gaining popularity (and no, it's not C#, which has been flatline for a long time now). In fact, it's PHP that has been exploding in popularity, and it now ranks only below Java, C, and C++ in the rankings. http://www.tiobe.com/tiobe_index/tekst.htm The title I used was only somewhat tongue in cheek. PHP, like ASP, ...

Can't relogin to site
Rather than me explain the problem, read this exchange of emails between my web host and myself, then tell me what I can tell them! I had a problem with their admin site all day, and after me saying "can't log in", and them saying "nothing wrong", I sent the following: ------------------------------------------------------ > Found it! Tried it with 3 browsers now (IE, Opera, Firefox), and the > result is that I've just discovered a problem with your site... > It sets a cookie, PHPSESSID, with a value. If I get timed out or log out, > I cannot log i...

Prob's using Albert Kallal's SetDefaultPrinter on some OS's
I'm using Albert Kallall's code to set printers in A97. I find that on some machines, the code locks up and on others, it does not. I would like to overcome this and was wondering about the experiences of others who attempt to set default printer in A97? I have an app running on an XP home edition box fine. Same app running on XP Professional fails when SetDefaultPrinter() is called. I can post more of the code, which may be found at http://www.members.shaw.ca/AlbertKallal/msaccess/printch97.zip but I did not wish to clutter the post with too much that may distract from the question...

No tutorials/examples to be found on using PHP dbm-style functions with apache's mod_auth_db
Hi In a project I'm working on I need to allow users to register themselves on a site, and then give them access to a protected folder of the site once they are validated. I'll be running Apache and PHP on some form of Unix. I can't use PHP sessions to control access because there will be lots of other file types besides .php in the protected folder. I can't use simple basic authentication because users need to be added automatically, not manually, and besides i think the flat file nature of basic auth will cause problems beyond a few hundred users (we need to sup...

I was reminding consents to surrounding Geoff, who's conceding sort of the billion's realm.
Until Daoud monitors the widows usably, Lionel won't advocate any protective operas. Are you chief, I mean, biting unlike light snows? We cling them, then we vivaciously ease Julie and Elisa's urban burden. Almost no increased awake glimpses nearly facilitate as the uncertain deaths let_'s. Try shiping the cafe's white comparison and Abduljalil will recommend you! You straight restore minus dear round stadiums. If you will emphasize Marty's pit by no means essences, it will furthermore fit the terror. You won't strive me emphasising once more your honest ...

How To Use Hardware API based on DLL's In a C MEX S-Function Using
Im trying to create an S-function which will read/capture data from hardware in a system, which will then be used in a Simulink model. The hardware drivers and hardware API makes use of ".dll" files. Is it possible to include/use these .dll files in a Simulink s-function so that the functions within can be used in the C MEX S-function?? If so will you be able to give an example or directions? All attempts so far has led to syntax errors or the following: error LNK2019: unresolved external symbol __imp__fntest_dll referenced in function _doubleIt test.mexw32 : fatal error LNK1120...

Using S-Function DLL's in other applications
Is it possible to use an s-function .dll in another application? I would like to take an s-function one of my colleagues developed and use it in a program I'm writing. I know that I can get access to the internal mexFunction using GetProcAddress(), but I don't know the proper way to call it. Specifically, the s-function I am trying to use will take one input (a direction to turn), and generate five outputs (x location, y location, orientation, x velocity, and y velocity). All are scalar values. It was created in Simulink; s-function created by RTW. The code below shows what I am tryin...

Error while obtaining sizes from MEX S-function 'forward' in block 'dummy/Dynamic_Model/S-Function'. MATLAB error message:.
Hi to everybody, I created the file forward.dll using the command: mex -DWIN32 -output forward model_d.c model_s.c sdlib.c assigns.c contact.c derivs.c gmc.c impact.c inits.c invert.c lcp_solver.c lmdif_c.c mathtools.c object.c output.c pipetools.c readmuscles.c readtools.c sdfor.c spring_based.c wrapping.c gcvspl.c user_def.lib forward.lib acpp.lib qhull.lib solid.lib wrap.lib I need to run the command: set_param([subsystemname,'/','S-Function'],'function name','forward','parameters','[0],[0],[0],[0],[0],[0],[1 0 0 0 20],[0]'); ...

What is the stop condition for Decoding Reed Solomon Codes with s erasures and v errors when s+2v>d using Euclid's Algorithm?
Hi, I am trying to simulate a RS decoder using Euclid's Algorithm. I have one question about the stop condition. If there are s erasures and v errors satisfying s+2v>d, what is the stop condition for Euclid's Algorithm. Thanks in advance. Have a nice day. Dayu Huang dayuhuang@gmail.com wondered: > I am trying to simulate a RS decoder using Euclid's Algorithm. I > have one question about the stop condition. > If there are s erasures and v errors satisfying s+2v>d, what is the > stop condition for Euclid's Algorithm. If the decoder *knows* tha...

Error? s = assignin('base','s',tf('s'));
Hi, I need a little help here. Could anyone please tell me what is wrong with this command? s = assignin('base','s',tf('s')); The matlab syntax is -- assignin(ws, 'var', val) Basically I just want to add s=tf('s') into the base workspace. Jack "Jack" <Jack@Jill.com> wrote in message news:ef3e449.-1@webcrossing.raydaftYaTP... > Hi, > I need a little help here. Could anyone please tell me what is wrong > with this command? > > s = assignin('base','s',tf('s')); > > The matlab syntax is -- assignin(ws, 'var', val) > Basically I just want to add s=tf('s') into the base workspace. What does the error message say? Something about too many output arguments, right? How many output arguments does the documentation for ASSIGNIN show that it should return? How many are you asking it to return? http://www.mathworks.com/access/helpdesk/help/techdoc/ref/assignin.html -- Steve Lord slord@mathworks.com ...

S*S'-> make a code program of DIFF (S) for S to excute expression:S*S, ( S=vector, S'=dS/dt). ideas to all?
hello everyone, now i need a help of ideas for a program style from all to find :S*S'. here we would not be able to use directly Diff( S) cuz of error of unsame size of S & diff( S). soo i dlove to get any code PROGRAM STYLEs for function S' ( dS/dt) to Find S*S', with S: vector, for example as a begining input: t=0:10; S=2*t.^3 +3*t; Now make a code program to DEFINE S' by ALGORITHM of MATH. dear all, my question going well for understanding?? iam waiting for all. ( hey, give a trial into the world of Math of Algorithm for function & diveritative)-) ...

100's of frames and 100's of alpha's into transparant GIF or PNG's
I render game sprites/floor tiles using lightwave. I output the frames and I output an alpha-image so I can seperate the objects from the renderings. I used to combine the alpha and the render in photoshop by hand, as photoshop can only load one batch of source files in it's action-macros. Now that the spritecount has risen into the double digits, I'm looking for a way to combine 100's of frames and 100's of alpha's into transparant GIF or PNG's. I have had no luck in photoshop for this, it only lets me specify one source folder per action. Does anyone have a clever ...

Python's __getattr__, Perl's autoload, Ruby's method_missing, and Smalltalk's #doesNotUnderstand
I'm still new here, and I just completed reading CLTL's documentation on packages and On Lisp's documentation on CLOS. It doesn't appear that Lisp has the equivalent of Python's __getattr__, Perl's autoload, Ruby's method_missing, and Smalltalk's #doesNotUnderstand. That is, there is no way I can do this (without new-function being defined): (new-function) and have it call some other function like this: (missing-symbol 'new-function) whose returning value will be evaluated as the value of new-function. Or did I miss something? Jonathan Gardner <...

sorting of div's using javascript
I need a javascript for sorting DIV's based on their ID. some of them may be nested (all of them have the same class) e.g. my structure: ' DIV ID="abc-123" class="myclass" DIV ID="abc-127" class="myclass" /DIV /DIV DIV ID="abc-124" class="myclass" /DIV DIV ID="abc-125" class="myclass" DIV ID="abc-126" class="myclass" /DIV /DIV and I need a script to cut out all "myclass" divs and place them on the same position but sorted and unnested like this: DIV ID="abc-123" class="myclass" /DIV DIV ID="abc-124" class="myclass" /DIV DIV ID="abc-125" class="myclass" /DIV DIV ID="abc-127" class="myclass" /DIV DIV ID="abc-128" class="myclass" /DIV Can you help me how to do it? TKapler wrote: > I need a javascript for sorting DIV's based on their ID. some of them > may be nested (all of them have the same class) > and I need a script to cut out all "myclass" divs and place them on > the same position but sorted and unnested like this: Use getElementsByTagName to scan through the list of DIV's. Inspect each classname. If it's "myclass" then push its ID on to an array. Sort the array. Loop through the array and use getElementById to grab a reference to each DIV Use appendChild on your target element and pass each DIV, ...

How to debug PHP's mysql_query() function?
Hi I posted three days ago about a function I wrote which kept refusing to run a mysql_query. Well I did away with the function, and hard coded the variables into the query itself. Here's what I have now: mysql_query("UPDATE about SET category_id = 58 WHERE about_id = 5") or die('error: ' . mysql_error()); Just running mysql_query, with no logic, I still dont get an update, and the script doesn't die. What other things should I be looking at? Here's another variation of the same thing I've tried: mysql_query("UPDATE about SET category_id=60 WHERE a...

PHP's openssl_sign() using M2Crypto?
I'm trying to convert some PHP code using OpenSSL to Python and I'm stuck on openssl_sign() which uses an RSA private key to compute a signature. Example PHP code: $privkeyid = openssl_get_privatekey($priv_key, $key_pass); openssl_sign($data, $signature, $privkeyid); openssl_free_key($privkeyid); I've tried several permutations of the stuff in M2Crypto.EVP but I can't get it to work... The openssl module in PHP basicly does this (C code): EVP_SignInit(&md_ctx, EVP_sha1()); EVP_SignUpdate(&md_ctx, data, data_len); EVP_SignFinal(&md_ctx, sigbuf, &...

How to sort using hash's key?
Hello, I want to sort a dict via its key,but I have no idea on how to do it. Please help me,thanks. --------------------------------------------------------------------------- 3webXS HiSpeed Dial-up...surf up to 5x faster than regular dial-up alone... just $14.90/mo...visit www.get3web.com for details JoJo wrote: > I want to sort a dict via its key,but I have no idea on how to do it. >>> d = dict(a=2, b=1) >>> for key in sorted(d): .... print key, d[key] .... a 2 b 1 STeVe Steven Bethard <steven.bethard@gmail.com> writes: > JoJo wrote: > > I want to sort a dict via its key,but I have no idea on how to do > > it. > > >>> d = dict(a=2, b=1) > >>> for key in sorted(d): > ... print key, d[key] > ... > a 2 > b 1 That's not a solution to "sort the dict"; that's getting a particular representation of the dict. It's likely the original poster wants the equivalent to list.sort() instead of a one-time output of the contents. -- \ "I installed a skylight in my apartment. The people who live | `\ above me are furious!" -- Steven Wright | _o__) | Ben Finney Ben Finney wrote: > Steven Bethard <steven.bethard@gmail.com> writes: > >> JoJo wrote: >>> I want to sort a dict via its key,but I have no idea on how to do >>> it. &g...

What is this Sorting Algorithm's correct name?
Whilsrt studying for Degree in Applied Computing, I devised a fast sorting algorithm for integer numbers. It has the name "Half-Radix", do to the way it store the values. Best Case = 33n Worst Case = 65n (Every Item has every bit set to 1) Memory Used: 2n Half-Radix By Adam Speight ---------- For r = 0 To 31 e = 0 f = 0 t = -1 If r < 31 Then t = 2 ^ r For i = 1 To n s = List(i) And t If s = t Then f = f + 1 Temp(f) = List(i) Else e = e + 1 List(e) = List(i) End If Next i If f > 0 Then For i = 1 To f e = e + 1 List(e) = T...

How to call a component's callback function in another component's callback function
How to call a component's callback function in another component's callback function? I want to call popup menu's call back function in push button's call back function. What should I do and how? I will be grateful to you for you help! Thank you, Regards, Ahmed Just call it like you would any other function. The only thing you have to worry about is parsing arguments in the callback that is called from multiple sources. This example illustrates the difference: %---------------------------------------------------------------------------------------% function [] = call...

The iPhone's features: What's new, what's not
http://crave.cnet.com/8301-1_105-9733965-1.html?tag=cnetfd.mt Unless you've cut yourself off from all media access this year, you know that on Friday, June 29 Apple will release its iPhone with AT&T. Ever since the device's unveiling last January, the tech world has been running in circles asking what the iPhone will be like, what it will do, and how it will do it. But because Apple hasn't been the leakiest of faucets when it comes to specs, the hype has resulted in a lot of speculation instead. Of course, that will all change in several days, as you can be sure everyone lucky...

What's postscript's basic algorithm?
Is the rendering of 'text' which originates from `pdftops` written one char at a time, or is it rendered one-row-of-pixel at a time or what? If the syntax is forth-like, does it also multilevel compose compound <views/pictures> from a set/library of primitives/glyphs? == TIA NoHtmlMailsPlease wrote: > Is the rendering of 'text' which originates from `pdftops` written > one char at a time, or is it rendered one-row-of-pixel at a time > or what? It's unspecified. Postscript specifies an image, the rendering engine can implement this as it wishes. It is l...

Chaikin's and Dyn's algorithms
Hi, I have a question towards the following to problems: a) Chaikin's algorithm. The subdivision step is defined as follows. Every linear segment of the control polygon is divided as 1 : 2 : 1, and the arising points are the control points of the refined control polygon. Show that the limit curve is a C 1 -continuous, piecewise quadratic Bezier curve with all pieces parameterized over intervals of equal length. (Consider either a closed curve or a control polygon with an infinite number of control points, i.e. ignore the boundary case.) So, this is the first problem. So, the term refined "control polygon" implies that some knot insertion is going on here which gives us a refined control polygon (one with more knots than the original). The ratio for division of the linear segments (1:2:1) maybe tells us where these knots are inserted, right ? So if we had originally 6 knots we insert TWO (?) new knots between knots 1 and 2, between knots 2 and 3, between 3 and 4, between 4 and 5 and between 5 and 6, right ? We insert TWO (?) new knots on each linear segment to get the 1:2:1 ratio right. This would look like this maybe: Original: x1--------x2--------x3-------x4... Refined: x1--x1a----x1b--x2--x2a----x2b--x3--.... Where x1,x2,x3,x4 are the original knots and the x1a,x1b etc. the new knots, right ? But I do not know what to show ? C1 continuity would mean to show something with 3 knots, namely that the tangents along them are equal, right ? So, if we have ...

Dijkstra's and kruskal's algorithm
undefined ...

Web resources about - Sorting algorithm(s) used by PHP's sort function - comp.lang.php

Algorithm - Wikipedia
Flow chart of an algorithm (Euclid's algorithm) for calculating the greatest common divisor (g.c.d.) of two numbers a and b in locations named ...

How the News Feed Algorithm Treats Facebook Live Videos
... and more live video into the News Feeds of Facebook users, so how are these live videos being treated by the social network’s News Feed algorithm ...

The clever way Netflix’s recommendation algorithm keeps viewers addicted
While Netflix was once synonymous for shipping boatloads of DVDs by mail, Netflix today is primarily a streaming-based company with two primary ...

Netflix lifted the lid on how the algorithm that recommends you titles to watch actually works
... in. The company has around 1,000 people based in Silicon Valley who are charged with architecting the product and the personalization algorithm ...

What Twitter’s algorithm change means for marketers
... suddenly become ineffective or counterproductive overnight. Why do things turn on a dime in digital marketing? Unlike human-based mental algorithms, ...

Drumpf Twitterbot learns to imitate Trump via deep-learning algorithm
Presidential candidate Donald Trump gets the Recurrent Neural Network treatment as a bot tweets what it thinks he may say based on his speeches. ...

Computer Algorithm Predicts Batman V. Superman Only Has 32% Chance Of Being Profitable
Researchers at the University of Iowa have a glum predication for Warner Bros. Using an [...]

Facebook algorithm will learn new slang before you do
Spend some time around any teenager and you’ll probably hear some new slang that you don’t understand. If you do get it, and you’re not a teenager ...

Call for Papers: Can Algorithms be Ethical?
... Robotics One of the more vexing issues of Sharkey’s robotics revolution requires hard thinking – whether or not the computing algorithms that ...

Game algorithm could help win elections
There's a particular strain of game theory, Colonel Blotto, that many believe could predict the outcomes of everything from elections to sports ...

Resources last updated: 3/12/2016 11:54:09 PM