Re: restating plea for help with sort

From: Date: Thu, 27 Feb 2003 19:13:13 +0000
Subject: Re: restating plea for help with sort
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-137458@lists.php.net to get a copy of this message
To append my own answer. In order to sort the non "n/a" values you're going to have to build a separate array and perhaps this will simplfy the problem. So instead of what I suggested below.. loop the array and start TWO new arrays within the loop. One array for "n/a" values and one for non-"n/a" values. After the values are sorted to their separate arrays do asort($nonnavals); then concatonate the two arrays together using array_merge(), putting the "n/a" array second. - Kevin ----- Original Message ----- From: "Kevin Stone" <kevin@helpelf.com> To: <jim@jimlong.net>; <php-general@lists.php.net> Sent: Thursday, February 27, 2003 12:04 PM Subject: Re: [PHP] restating plea for help with sort > Hmm well upon first glance looks like all you need to do is loop that array > and start a new array within the loop. An If/Else construct checks If the > value is "n/a" then append to the back of the new array Else prepend to the > front of the new array. You append the values manually or use > array_push() and array_unshift(). Search the manual for more information. > Hope that helps. > - Kevin > > ----- Original Message ----- > From: "Jim Long" <jim@jimlong.net> > To: <php-general@lists.php.net> > Sent: Thursday, February 27, 2003 11:35 AM > Subject: [PHP] restating plea for help with sort > > > > 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/"é#gŒU#†ÿŒƈ‡ > > À>another place</a>' => $vendor2__total, > > [snip] etc.. > > > > some vals are numeric and some vals are "n/a" > > asort works to sort the array as a string, however, I need to sort the > > numeric vals numeric, then have the n/a's go away or be output at the > > bottom of the sort. > > > > Please be clear and gentle.. I'm not schooled in php, just a tinkerer > > trying to make this mess work. > > > > Thanks In Advance, > > > > Jim Long > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >

« previous php.general (#137458) next »