Re: [PHP] usort within a class

2011-04-18 Thread Stuart Dallas
On Monday, 18 April 2011 at 21:52, Ashley Sheridan wrote: On Mon, 2011-04-18 at 21:41 +0100, Stuart Dallas wrote: > > On Monday, 18 April 2011 at 21:27, Ashley Sheridan wrote: > > I'm trying to get the usort function working inside of a class, but am > > > having some issues. Basically, the compare

Re: [PHP] usort within a class

2011-04-18 Thread Ashley Sheridan
On Mon, 2011-04-18 at 21:41 +0100, Stuart Dallas wrote: > On Monday, 18 April 2011 at 21:27, Ashley Sheridan wrote: > I'm trying to get the usort function working inside of a class, but am > > having some issues. Basically, the compare function which is the second > > parameter isn't recognised, bu

Re: [PHP] usort within a class

2011-04-18 Thread Stuart Dallas
On Monday, 18 April 2011 at 21:27, Ashley Sheridan wrote: I'm trying to get the usort function working inside of a class, but am > having some issues. Basically, the compare function which is the second > parameter isn't recognised, but I'm not really sure how to indicate > exactly where it is. >

Re: [PHP] usort for sorting an array of objects

2008-12-10 Thread Robert Cummings
On Thu, 2008-12-11 at 11:44 +1300, German Geek wrote: > On Thu, Dec 11, 2008 at 6:43 AM, Robert Cummings <[EMAIL PROTECTED]>wrote: > > > On Thu, 2008-12-11 at 01:31 +1300, German Geek wrote: > > > On Wed, Dec 10, 2008 at 10:27 PM, Stut <[EMAIL PROTECTED]> wrote: > > > > > > > On 10 Dec 2008, at 04

Re: [PHP] usort for sorting an array of objects

2008-12-10 Thread German Geek
On Thu, Dec 11, 2008 at 12:28 PM, <[EMAIL PROTECTED]> wrote: > > > Inefficiency for me is when it takes longer to code. > > How long can this take? That's why i like PHP. It's very quick to do stuff in, even if arrays are not always the ultimate data structure, they're easy to handle with all the

Re: [PHP] usort for sorting an array of objects

2008-12-10 Thread ceo
> Inefficiency for me is when it takes longer to code. How long can this take? Even if you go full-blown with an Interface and static methods that have to be fleshed out in the implementations, you're still talking about an hour or so. Quit complaining and start typing. :-) > PHP is

Re: [PHP] usort for sorting an array of objects

2008-12-10 Thread Shiplu
PHP is a scripting language. Everytime the compiler has to parse the source. You can not except true OOP performance. OOP behavior is okay. If performance is the main factor, an C extension will do that. -- Blog: http://talk.cmyweb.net/ Follow me: http://twitter.com/shiplu -- PHP General Mailing

Re: [PHP] usort for sorting an array of objects

2008-12-10 Thread German Geek
On Thu, Dec 11, 2008 at 6:43 AM, Robert Cummings <[EMAIL PROTECTED]>wrote: > On Thu, 2008-12-11 at 01:31 +1300, German Geek wrote: > > On Wed, Dec 10, 2008 at 10:27 PM, Stut <[EMAIL PROTECTED]> wrote: > > > > > On 10 Dec 2008, at 04:15, German Geek wrote: > > > > > >> I need to sort an array of ob

Re: [PHP] usort for sorting an array of objects

2008-12-10 Thread ceo
You can use a (base) object Comparable with a method compareTo as the callback function for http://php.net/usort That gives you 99% of what you want, for the tiny price of having to pass in the array('Comparable','compareTo') as the callback arg. Given that one frequently calls usort and f

Re: [PHP] usort for sorting an array of objects

2008-12-10 Thread Shiplu
may be you can design a class. interface ISortable{ public sort(); public compare($a,$b); } SortableList implements ISortable { } -- Blog: http://talk.cmyweb.net/ Follow me: http://twitter.com/shiplu -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/u

Re: [PHP] usort for sorting an array of objects

2008-12-10 Thread Robert Cummings
On Thu, 2008-12-11 at 01:31 +1300, German Geek wrote: > On Wed, Dec 10, 2008 at 10:27 PM, Stut <[EMAIL PROTECTED]> wrote: > > > On 10 Dec 2008, at 04:15, German Geek wrote: > > > >> I need to sort an array of objects. I found this ( at a url that didnt let > >> me send this msg... ) and I would kn

Re: [PHP] usort for sorting an array of objects

2008-12-10 Thread German Geek
On Wed, Dec 10, 2008 at 10:27 PM, Stut <[EMAIL PROTECTED]> wrote: > On 10 Dec 2008, at 04:15, German Geek wrote: > >> I need to sort an array of objects. I found this ( at a url that didnt let >> me send this msg... ) and I would know how to do it, but I believe there >> might be a cleaner, more e

Re: [PHP] usort for sorting an array of objects

2008-12-10 Thread Stut
On 10 Dec 2008, at 04:15, German Geek wrote: I need to sort an array of objects. I found this ( at a url that didnt let me send this msg... ) and I would know how to do it, but I believe there might be a cleaner, more elegant way to do it. In Java, you just need to implement the interface Co

Re: [PHP] usort inside a class

2008-05-09 Thread It flance
It works thanks a lot! --- On Fri, 5/9/08, Richard Heyes <[EMAIL PROTECTED]> wrote: > From: Richard Heyes <[EMAIL PROTECTED]> > Subject: Re: [PHP] usort inside a class > To: [EMAIL PROTECTED] > Cc: php-general@lists.php.net > Date: Friday, May 9, 2008, 8:47 PM >

Re: [PHP] usort inside a class

2008-05-09 Thread Richard Heyes
i'm trying to build a class that sorts a multidimensional array. I'm using the php function "usort". I declared the comparision function as a method of my class but i'm unable to give it as argument to the function usort. this "usort($this->arr, $this->cmpi)" gaves the following error: usort()

RE: [PHP] usort within a class

2006-08-23 Thread Peter Lauri
Working perfect, thanks :) I did RTFM but I did miss that :) -Original Message- From: Robert Cummings [mailto:[EMAIL PROTECTED] Sent: Thursday, August 24, 2006 3:46 AM To: Peter Lauri Cc: php-general@lists.php.net Subject: Re: [PHP] usort within a class On Thu, 2006-08-24 at 03:13 +0700

Re: [PHP] usort within a class

2006-08-23 Thread Robert Cummings
On Thu, 2006-08-24 at 03:13 +0700, Peter Lauri wrote: > Hi, > > Is it possible to have the compare function in a class? I can not get it to > work, this is pseudo code: > > class A { >function getArray() { > //dosomethingandgetanarray > $array = blabla; > usort($array, "$thi

Re: [PHP] usort(): The argument should be an array

2006-02-28 Thread Thorsten Suckow-Homberg
$row[4]; $res[$i]['size'] = $row[5]; $res[$i]['weight'] = $result_array[$row[0]]; $i++; } usort($res, "cmp"); echo mysql_error(); $res['maxweight'] = $maxweight; $res['results'] = $results; return $res; /**/ } ?> That's not enough, we need the part that sits above an

Re: [PHP] usort(): The argument should be an array

2006-02-28 Thread Robin Vickery
On 28/02/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > Can anyone comment and fix this error > > Warning: usort(): The argument should be an array in > /home2/wwwabcde/public_html/search/searchfuncs.php on line 300 [...] > usort($res, "cmp"); Put a print_r($res) a

Re: [PHP] usort e & é together

2004-07-11 Thread John Taylor-Johnston
Sorry, doesn't work either. http://compcanlit.usherbrooke.ca/new1/db/index.php?ausenquiry=e does not contain those that start with é: http://compcanlit.usherbrooke.ca/new1/db/index.php?ausenquiry=é function usort_callback($a, $b) { $a = str_replace(array('à', 'é'), array('a', 'e'), strtolow

Re: [PHP] usort e & é together

2004-07-11 Thread John Taylor-Johnston
Thanks! What does var_dump do? (I didn't really understand the manual.) "Miroslav Hudak (php/ml)" wrote: > Pardon me for the strtolower line, i've just forgot there... it's 4:30AM > here in Slovakia... :/ > > correct listing follows... > > $authors = array('élen', 'Élen', 'Elison', 'ámadeus', 'a

Re: [PHP] usort e & é together

2004-07-11 Thread Miroslav Hudak (php/ml)
Pardon me for the strtolower line, i've just forgot there... it's 4:30AM here in Slovakia... :/ correct listing follows... $authors = array('élen', 'Élen', 'Elison', 'ámadeus', 'albert', 'alfred', 'amadeus', 'elen'); function usort_callback($a, $b) { $a = str_replace(array('á', 'é'), array

Re: [PHP] usort e & é together

2004-07-11 Thread Miroslav Hudak (php/ml)
this is slightly changed function of yours, written for better readability... $authors = array('élen', 'Élen', 'Elison', 'ámadeus', 'albert', 'alfred', 'amadeus', 'elen'); function usort_callback($a, $b) { $a = strtolower($a); $b = strtolower($b); $a = str_replace(array('á', 'é'), arra

Re: [PHP] usort e & é together

2004-07-11 Thread John Taylor-Johnston
http://compcanlit.usherbrooke.ca/new1/db/index.php?ausenquiry=e http://compcanlit.usherbrooke.ca/new1/db/index.php?ausenquiry=é It still sorts "é" and "e" separately, but without a parse error: $first = array('à', 'é'); $second = array('a', 'e'); usort($authors, create_function('$a,$b','

Re: [PHP] usort e & é together

2004-07-11 Thread Marek Kilimajer
John Taylor-Johnston wrote: I think my problem lies in usort. I have a big honker of an array which I usort. $ausenquiry = "e"; and $ausenquiry = "e"; give a separate result. I want to conjoin them. Possible? The same would be true for "a" and "à". usort distinguishes between é and e. Any way aroun

RE: [PHP] Usort an array.

2003-11-20 Thread Jay Frumkin
Try using rsort() Jay -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP] usort

2003-10-27 Thread Justin Patrin
No need to write your own function, it's already in PHP. :-) What you're looking for it natsort(). It uses natural order string comparison (which takes into account numbers instead of just using characters like a regular search does). There are also lots of other 'nat' functions, such as strnat

Re: [PHP] usort

2003-10-24 Thread David Otton
On Sat, 25 Oct 2003 04:03:12 +0300, you wrote: >I don't know what the names are. I just know that there might be numbers. :) > >It still doesn't work. It gives very odd results with the $x_out variables. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.n

Re: [PHP] usort

2003-10-24 Thread Shmuel
Curt Zirzow wrote: * Thus wrote Shmuel ([EMAIL PROTECTED]): file_1.ext file_2.ext file_3.ext file_10.ext file_40.ext function mycmp($a, $b) { if ($a == $b) { return 0; } $a_n = preg_match("/\D+(\d+)\D+/", $a, $a_out); $b_n = preg_match("/\D+(\d+)\D+/

Re: [PHP] usort

2003-10-24 Thread Curt Zirzow
* Thus wrote Shmuel ([EMAIL PROTECTED]): > file_1.ext > file_2.ext > file_3.ext > file_10.ext > file_40.ext > > function mycmp($a, $b) { > if ($a == $b) { > return 0; > } > $a_n = preg_match("/\D+(\d+)\D+/", $a, $a_out); > $b_n = preg_match("/\D+(\d+)\

Re: [PHP] Usort

2003-04-03 Thread Jonathan Pitcher
Thank you. I now have it working and it makes sense. Jonathan On Thursday, April 3, 2003, at 04:26 PM, Ernest E Vogelsinger wrote: [snip] The compare callback is expected to return anything < 0 if the first value is less than the second (should sort _be

Re: [PHP] Usort

2003-04-03 Thread Ernest E Vogelsinger
At 23:53 03.04.2003, Jonathan Pitcher said: [snip] >This email is long I apologize for that. It is my code and then what >it returns and what I am wanting it to return. I don't think I >understand how USORT works or even if I am using the right function f