http://php.net/manual/en/function.usort.php
function cmp($a, $b)
{
if ($a['key1'] == $b['key1']) {
if ($a['key2'] == $b['key2']) {
return 0;
}else{
return ($a['key2'] < $b['key2']) ? -1 : 1;
}
}else{
return ($a['key1'] < $b['key1']) ? -1 : 1;
}
}
Something like that
On Mon, Jul 30, 2012 at 10:37 AM, heohni <
[email protected]> wrote:
> a) in this case, the DB can't help as the array contains data I put
> manually in
> b) It's not that urgent and I was hoping I was just overseeing
> something... If you just telling me that I cannot use 2 sort rules, I will
> arrange my array in another way to get to my goal.
>
> Thanks :-)
>
> Am Montag, 30. Juli 2012 09:34:39 UTC+2 schrieb euromark:
>
>> a) why not providing the data correctly sorted from the db level? let
>> mysql do the work
>>
>> b) if that is not possible for some reason, why not manually iterating
>> over the array? probably still faster than the Set/Hash class anyway.
>> yeah, might be a few lines more, but at least you got it in a few minutes
>> instead of waiting for some guru to write it for you.
>>
>>
>> Am Montag, 30. Juli 2012 09:05:06 UTC+2 schrieb heohni:
>>>
>>> does anyone has an idea?
>>>
>>> Am Freitag, 27. Juli 2012 12:36:15 UTC+2 schrieb heohni:
>>>>
>>>> Hi,
>>>>
>>>> I have this array:
>>>> Array
>>>> (
>>>> [240] => Array
>>>> (
>>>> [Member] => Array
>>>> (
>>>> [id] => 112
>>>> )
>>>>
>>>> [Payment] => Array
>>>> (
>>>> [date] => 0712
>>>>
>>>>
>>>> )
>>>> )
>>>>
>>>> I want to use the set::sort function to sort first for Member.id ASC
>>>> and then for Payment.ASC
>>>>
>>>> Can please someone explain me how I need to write the set::sort syntax?
>>>> I never used it before and quite unsure how it has to be done.
>>>>
>>>> Thanks!!
>>>>
>>>>
>>>> --
> Our newest site for the community: CakePHP Video Tutorials
> http://tv.cakephp.org
> Check out the new CakePHP Questions site http://ask.cakephp.org and help
> others with their CakePHP related questions.
>
>
> To unsubscribe from this group, send email to
> [email protected] For more options, visit this group
> at http://groups.google.com/group/cake-php
>
--
Regards,
Zaky Katalan-Ezra
QA Administrator
www.IGeneriX.com
Sites.IGeneriX.com
054-7762312
--
Our newest site for the community: CakePHP Video Tutorials
http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others
with their CakePHP related questions.
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at
http://groups.google.com/group/cake-php