How can I sort this array of objects with many properties in PHP?
===

I have an array that contains multiple objects with many properties.

I want to sort it in PHP base on two object properties

Here's a sample array of objects to give you an idea of what data i'm dealing with:

    Array (
        [0] => stdClass Object (
            [username] => user98
            [sender_id] => 98
            [date_sent] => 2012-07-25 00:52:11
            [not_read] => 0
        )
        [1] => stdClass Object (
            [username] => user87
            [sender_id] => 87
            [date_sent] => 2012-07-25 00:59:15
            [not_read] => 1
        )
        [2] => stdClass Object (
            [username] => user93
            [sender_id] => 93
            [date_sent] => 2012-07-25 00:52:13
            [not_read] => 2
        )
        [3] => stdClass Object (
            [username] => user5
            [sender_id] => 5
            [date_sent] => 2012-07-25 00:52:16
            [not_read] => 0
        )
    )

I need to sort it resulting to this array:

    Array (
		[1] => stdClass Object (
            [username] => user87
            [sender_id] => 87
            [date_sent] => 2012-07-25 00:59:15
            [not_read] => 1
        )
        [2] => stdClass Object (
            [username] => user93
            [sender_id] => 93
            [date_sent] => 2012-07-25 00:52:13
            [not_read] => 2
        )
        [3] => stdClass Object (
            [username] => user5
            [sender_id] => 5
            [date_sent] => 2012-07-25 00:52:16
            [not_read] => 0
        )
        
        [0] => stdClass Object (
            [username] => user98
            [sender_id] => 98
            [date_sent] => 2012-07-25 00:52:11
            [not_read] => 0
        )
        
        
    )

The sorting is based on the date property and the not_read property of the object, the not_read > 0 is prioritized first in the sorting, then it will look at the date_sent property and sort it on the latest date_sent. Note that it is not based on who has the higher not_read property.

Then those with 0 not_read property will be sorted by latest date_sent.

Can anyone help me with this program?

thanks a lot of looking!