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

Ask a Question related to PHP Development, Design and Development.

  1. #1

    Default 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?
    Shaunak Kashyap Guest

  2. Similar Questions and Discussions

    1. Problem with SQL Statement/Sort Function
      Hey everyone, I am inserting a drop down menu that will allow a user to sort the database result on my page. The problem is, i'm not sure where to...
    2. Ado sort error-Ado Sort -Relate, Compute By, or Sort operations cannot be done on column(s) whose key length is unknown or exceeds 10 KB.
      Ado Sort -Relate, Compute By, or Sort operations cannot be done on column(s) whose key length is unknown or exceeds 10 KB. hi, guys i have asp...
    3. California ballot sort algorithm?
      >>>>> "Kevin" == Kevin Zembower <kzembowe@jhuccp.org> writes: Kevin> Here's a sure sign of someone with too much time on his hands: Kevin> I was...
    4. Sorting out sort
      I'm trying to extract a column from a flatfile database and print it alphabetically. I can get the data out, but I can't get it to sort. The...
    5. [Q] Safari, Javascript and sort function
      Hello, I'm looking for a script to sort a html table. On the web, I found a lot of js scripts to do that but none working with Safari. Someone...
  3. #2

    Default Re: Sorting algorithm(s) used by PHP's sort function

    "Shaunak Kashyap" <skashyap@intertechmedia.com> wrote in message
    news:67746bb.0307241733.63a5649f@posting.google.co m...
    > 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


    Zac Hester Guest

  4. #3

    Default 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?


    Shaunak Kashyap Guest

  5. #4

    Default Re: [PHP] Sorting algorithm(s) used by PHP's sort function

    * Thus wrote Shaunak Kashyap (skashyap@intertechmedia.com):
    > Does anyone know what sorting algorithm(s) -- quicksort, mergesort,
    > radix sort, etc. -- does PHP use internally in its sort function?
    Zend actually does the sorting, and its quicksort.

    Curt
    --
    "I used to think I was indecisive, but now I'm not so sure."
    Curt Zirzow Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139