Re: [PHP-DB] Sorting a 2 dimension array

2001-10-05 Thread Robert Gormley

Is ksort() what you're looking for?

Sorts an array by key, maintaining key to data correlations.

Robert

At 05:31 PM 5/10/2001 +0930, John Clarke wrote:
I would like to sort a 2 dimensional array based on the value of one of the
keys of each element.

I have an array returned from a msql query which contains 10
records/elements and each record 5 fields/keys.
I would like to sort the records based on the value of a particular field in
each record.

Is this possible.? I have looked thru all the array functions but cannot
seem to find anything that allows me to do this.

I dont want to write a separate peice of code to compare all of these
elements and their values and then place them into a new array in the
correct order if there is a simpler way of achieving it.

Any comments would be greatly appreciated.

Regards,

John Clarke



--
PHP Database 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]



-- 
PHP Database 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]




RE: [PHP-DB] Sorting a 2 dimension array

2001-10-05 Thread Beau Lebens

although i've never used it, sounds like you would need to use the uasort()
function, and write a custom comparison function - tho don't ask me how to
do that :P

HTH

Beau

// -Original Message-
// From: John Clarke [mailto:[EMAIL PROTECTED]]
// Sent: Friday, 5 October 2001 4:01 PM
// To: [EMAIL PROTECTED]
// Subject: [PHP-DB] Sorting a 2 dimension array
// 
// 
// I would like to sort a 2 dimensional array based on the 
// value of one of the
// keys of each element.
// 
// I have an array returned from a msql query which contains 10
// records/elements and each record 5 fields/keys.
// I would like to sort the records based on the value of a 
// particular field in
// each record.
// 
// Is this possible.? I have looked thru all the array 
// functions but cannot
// seem to find anything that allows me to do this.
// 
// I dont want to write a separate peice of code to compare all of these
// elements and their values and then place them into a new array in the
// correct order if there is a simpler way of achieving it.
// 
// Any comments would be greatly appreciated.
// 
// Regards,
// 
// John Clarke
// 
// 
// 
// -- 
// PHP Database 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]
// 

-- 
PHP Database 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]




Re: [PHP-DB] Sorting a 2 dimension array

2001-10-05 Thread Steve Farmer

Hi,

Why don't you sort the query to MYSQL and have the records delivered 
in the order you want them?

HTH
Steve
At 5:31 PM +0930 5/10/01, John Clarke wrote:
I would like to sort a 2 dimensional array based on the value of one of the
keys of each element.

I have an array returned from a msql query which contains 10
records/elements and each record 5 fields/keys.
I would like to sort the records based on the value of a particular field in
each record.

Is this possible.? I have looked thru all the array functions but cannot
seem to find anything that allows me to do this.

I dont want to write a separate peice of code to compare all of these
elements and their values and then place them into a new array in the
correct order if there is a simpler way of achieving it.

Any comments would be greatly appreciated.

Regards,

John Clarke



--
PHP Database 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]

-- 
-
Minds are like parachutes, they work best when open
Support free speech; visit http://www.efa.org.au/

Heads Together Systems Pty Ltd http://www.hts.com.au
Email: [EMAIL PROTECTED] Tel: 612 9982 6767 Fax: 612 9981 3081 

-- 
PHP Database 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]