先贴代码:

[codesyntax lang="php"]
<?php

require_once('redis.php');
$redis = new Redis();
$redis->connect();
$uid=111;
$fried_uid_list = array(123,456,789,101);
//增加好友
foreach ($fried_uid_list as $v)
{
$redis->sadd($uid.':friend:list' ,$v);
}
//uid:sort:123
//uid对应的积分
$redis->set('uid:sort:111',9000);
$redis->set('uid:sort:123',1000);
$redis->set('uid:sort:456',6000);
$redis->set('uid:sort:789',100);
$redis->set('uid:sort:101',5999);

//uid infor
$use_infor_list = array(
111=>array('uid'=>111,'name'=>'wgr'),
123=>array('uid'=>123,'name'=>'lucy'),
456=>array('uid'=>456,'name'=>'marry'),
789=>array('uid'=>789,'name'=>'ice'),
101=>array('uid'=>101,'name'=>'jack'),
);
foreach ($use_infor_list as $v)
{
$redis->set('uid:'.$v['uid'] , json_encode($v));
}
$result = $redis->sort('111:friend:list by uid:sort:* get uid:* ' );
var_dump($result);
?>

[/codesyntax]
结果是:
array(4) {
[0]=>
string(24) "{"uid":789,"name":"ice"}"
[1]=>
string(25) "{"uid":123,"name":"lucy"}"
[2]=>
string(25) "{"uid":101,"name":"jack"}"
[3]=>
string(26) "{"uid":456,"name":"marry"}"