On 22 June 2006 02:22, weetat wrote:
Hi all,
I have multi-arrays as shown below:
I implemented usort() to sort the array by 'country' field
in the array.
However there some empty string value in the array and i setup my
cmpcountry() function to sort array, however , some country
Hi all,
I have multi-arrays as shown below:
I implemented usort() to sort the array by 'country' field in the array.
However there some empty string value in the array and i setup my
cmpcountry() function to sort array, however , some country empty string
value are sort first .
Any ideas
Examine your function for the case of cmpcountry(Thailand, );
if($country2 == '') is true
if($country1 $country2) is false
Then ($country1 $country2) is false again and 1 is returned.
This means that is less than Thailand, and should be sorted higher.
The easiest way to fix this is actually
Hi David ,
Thanks for your input, it solve my problem.
David Tulloh wrote:
Examine your function for the case of cmpcountry(Thailand, );
if($country2 == '') is true
if($country1 $country2) is false
Then ($country1 $country2) is false again and 1 is returned.
This means that is less
I´ve in a array the coluns: date , weekday , hour , etc...
I need to sort him by coluns 0 and 2 but not found the correctly function to
do it.
Please, anyone know how can i do?
Thanks.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
João Cândido de Souza Neto wrote:
I´ve in a array the coluns: date , weekday , hour , etc...
I need to sort him by coluns 0 and 2 but not found the correctly function to
do it.
Take a look at this manual page:
http://www.php.net/manual/en/function.array-multisort.php
Regards,
Torgny
--
PHP
I've been banging my head against the wall on this one. Probably
trivial to the knowledgeable, but I'm stumped despite trying the various
sort functions as advertised on php.net.
I've got the following fields:
retailer city state telephone distance
Sample data looks like:
BLIND BROOK
This was just discusses in quite some detail. Everyone decieded that
usort() was the best and a couple peopel agreed that array_multisory()
works just fine. Check out that convo to get some pretty good details
on how to do this.
On Tue, 05 Oct 2004 13:04:44 -0400, Kevin Coyner [EMAIL PROTECTED]
I have been messing around now for some hours and Im going mad!
Im pulling some heavy data from mySQL with count and grouping,
after this I have to calculate som values and then sort the outcome.
Therefore Im not able to let mySQL do the accuall sort.
So i stuff it into an array, and I need to
Hi,
Thursday, February 5, 2004, 11:35:34 PM, you wrote:
KS I have been messing around now for some hours and Im going mad!
KS Im pulling some heavy data from mySQL with count and grouping,
KS after this I have to calculate som values and then sort the outcome.
KS Therefore Im not able to let
I have an array of object for files on my site. The objects hold a file's
name, size, extension, etc... I was wondering if anyone knows where I could
find a relatively easy function for sorting the array of these objects by
either name, size, etc... Please let me know if got any tips. Thanks a
Matt Palermo wrote:
I have an array of object for files on my site. The objects hold a file's
name, size, extension, etc... I was wondering if anyone knows where I could
find a relatively easy function for sorting the array of these objects by
either name, size, etc... Please let me know if got
Hi,
I have an array with an html link as key and different $vars as val:
$list = array (
'a href=http://someplace.com/;some place/a' = $vendor1_total,
'a href=http://anotherplace.com/;another place/a' = $vendor2__total,
[snip] etc..
some vals are numeric and some vals are n/a
asort works to
Hi,
I have following filename/date array
Array ( [0] = Array ( [0] = 1.jpg [1] = 10.jpg [2] = 11.jpg [3] =
12.jpg [4] = 2.jpg [5] = 3.jpg [6] = 4.jpg [7] = 5.jpg [8] =
6.jpg [9] = 7.jpg [10] = 8.jpg [11] = 9.jpg ) [1] = Array ( [0] =
1026502301 [1] = 1026502312 [2] = 1026502313 [3] = 1026502550
Hi,
I have following filename/date array
Array ( [0] = Array ( [0] = 1.jpg [1] = 10.jpg [2] = 11.jpg [3] =
12.jpg [4] = 2.jpg [5] = 3.jpg [6] = 4.jpg [7] = 5.jpg [8] = 6.jpg [9]
= 7.jpg [10] = 8.jpg [11] = 9.jpg ) [1] = Array ( [0] = 1026502301 [1]
= 1026502312 [2] = 1026502313 [3] = 1026502550
Hi,
I have following filename/date array
Array ( [0] = Array ( [0] = 1.jpg [1] = 10.jpg [2] = 11.jpg [3] =
12.jpg [4] = 2.jpg [5] = 3.jpg [6] = 4.jpg [7] = 5.jpg [8] =
6.jpg [9] = 7.jpg [10] = 8.jpg [11] = 9.jpg ) [1] = Array ( [0] =
1026502301 [1] = 1026502312 [2] = 1026502313 [3] = 1026502550
Hi All,
I'm trying to sort an array of objects by the value of one of those
objects...
for instance, I'll have an object with 2 properties, id and score, where
id is unique and score is its relevant (and sometimes simelar) score. i've
tried using sort() and asort() but i can't figure how to
*/
- Original Message -
From: Aaron Bennett [EMAIL PROTECTED]
To: Php-General (E-mail) [EMAIL PROTECTED]
Sent: Sunday, July 08, 2001 4:25 AM
Subject: [PHP] Sort an array by its values
| Hi All,
| I'm trying to sort an array of objects by the value of one of those
| objects
: Sunday, July 08, 2001 1:33 AM
To: Aaron Bennett
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP] Sort an array by its values
Do you mean something like www.php.net/ksort or www.php.net/krsort?
I'm not sure of the actual structure of your array, though, so those might
not work as expected.
/* Chris Lambert
PROTECTED]; Aaron
Bennett [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Sent: Sunday, July 08, 2001 4:34 AM
Subject: RE: [PHP] Sort an array by its values
| Chris,
| I'm looking at ksort as i type... the problem i'm having is that i'm
| trying to sort a value inside an object inside that array (rather
: [PHP] Sort an array by its values
Hi All,
I'm trying to sort an array of objects by the value of one of those
objects...
for instance, I'll have an object with 2 properties, id and
score, where
id is unique and score is its relevant (and sometimes simelar) score. i've
tried using sort
-
From: Chris Lambert - WhiteCrown Networks [mailto:[EMAIL PROTECTED]]
Sent: Sunday, July 08, 2001 1:38 AM
To: Aaron Bennett
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP] Sort an array by its values
Can you print_r($variable) and post it here?
/* Chris Lambert, CTO - [EMAIL PROTECTED]
WhiteCrown
Try something like:
uasort($your_hash[$first_level][$any_second_level],
create_function('$a,$b', 'return $a[what_level] -
$b[what_level];'));
and adjust this according to the level and what you want to sort on
accordingly...
_jef
Aaron Bennett wrote:
Hi All,
Hello,
Is there a way to sort an array alphabetically?
Brandon
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]
The PHP online manual is very easy to use. Start at
http://www.php.net/array and you'll find all the functions that act on
array downl the left side of your browser, including a fantastically rich
set of sort options.
Miles
At 12:19 PM 4/30/01 -0700, Brandon Orther wrote:
Hello,
Is there a
Hello,
i have this code:
while ($row = mysql_fetch_array($results)) {
$tmp = get_item_reorder_priority($row["item_sku"]);
$list[$r]["priority"] = $tmp[0];
$list[$r]["sku"] = $row["item_sku"];
$r++;
}
$list = array_multisort($list["priority"], SORT_NUMERIC, SORT_DESC);
while ($row = mysql_fetch_array($results)) {
$tmp = get_item_reorder_priority($row["item_sku"]);
$list[$r]["priority"] = $tmp[0];
$list[$r]["sku"] = $row["item_sku"];
$r++;
}
$list = array_multisort($list["priority"], SORT_NUMERIC, SORT_DESC);
and it returns this
I'm still confused. I'm looking to sort the list[$r] part of the array based
on what value $list[$r]["priority"] is. What would the function's arguments
be?
""Stuart J. Browne"" [EMAIL PROTECTED] wrote in message
99rajk$i0v$[EMAIL PROTECTED]">news:99rajk$i0v$[EMAIL PROTECTED]...
while ($row =
28 matches
Mail list logo