Sorting array with special condition

Hello,

I have a multidimensional array such as below:

array(5) {
[0]=>
array(3) {
[“id”]=>
string(4) “3140”
[“user_id”]=>
string(1) “1”
[“priority”]=>
string(1) “1”
}

[1]=>

array(3) {
[“id”]=>
string(4) “3148”
[“user_id”]=>
string(1) “2”
[“priority”]=>
string(1) “1”
}

[2]=>

array(3) {
[“id”]=>
string(4) “4140”
[“user_id”]=>
string(1) “8”
[“priority”]=>
string(1) “1”
}

[3]=>
array(3) {
[“id”]=>
string(4) “2340”
[“user_id”]=>
string(1) “5”
[“priority”]=>
string(1) “0”
}

[4]=>
array(3) {
[“id”]=>
string(4) “2341”
[“user_id”]=>
string(1) “5”
[“priority”]=>
string(1) “0”
}
}

The arrays with priority=1 are sorted in front arrays with priority=0.

I wish to sort the array with priority=1 randomly, the order of arrays with priority=0 will remain behind all arrays with priority=1.

How can I sort the arrays without affecting the order of array with priority=0?

http://www.php.net/manual/en/function.uasort.php

To get random order of priority 0 just randomly return > < = if both elements are 0.