sorting screws up listData format

Hi. I am performing two queries. Both result sets I array_merge into one array and than I perform a listData to the merged array. However, I would like to sort the listData elements in an alphabetic order. I do that via sort(), however, than I get:


Invalid argument supplied for foreach()

Any advice how to sort the listData would be greatly appreciated.

cheers,

bettor

use php’s native sort()

thanks for your time jayrulez. As I have mentioned in my post I have already tried sort() but it messes things up and I get the above mentioned error.

Show a sample of the data you are trying to sort.

this doesn’t work:




		$allnames=array_merge((array)$names_host,(array)$names_away);


            return sort($allnames);

this works tho without the sort:




		$allnames=array_merge((array)$names_host,(array)$names_away);


            return $allnames;

thanks jayrulez

Please have a look at http://php.net/manual/en/function.sort.php

sort returns a boolean value so returning sort will return true or false.

the correct way




$allnames=array_merge((array)$names_host,(array)$names_away);

sort($allnames);

return $allnames;



Ah, thanks for noticing this.