Re: Re: Extracting multi dimensional array value

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Sorting is definitely slower than going through once c or php. The speed of
the algorithm is always more important than the language. There may be a
slow down with php but it will always be O(1) and that is negligible. So
unless you have only 2 items in the list where only 2 permutations are
possible sorting will be slower. min()  or max() are the functions to use
if possible. for each is a language construct and should be having c like
performance. C is not always faster. It's not a magic silver bullet to
increase performance. Yes, you probably have fewer machine instructions on
most things and don't get me wrong, I love c but if the algorithm is slower
c can be slower than php.

On Sun, 3 May 2015 11:10 pm Christoph Becker <cmbecker69@xxxxxx> wrote:

> German Geek wrote:
>
> > Sorting is always more expensive than going through the array once.
>
> That's a good point!
>
> > I would
> > just iterate through once and keep track of the smallest or largest
> element
> > by storing the smallest or largest element in a temporary variable. There
> > should really be a php function for that.
>
> Actually, there is: min(), which seems to be the simplest and most
> efficient solution for Ron's task.
>
> --
> Christoph M. Becker
>

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux