递归+冒泡对数组排序
要实现的效果, 外层是对的
static/image/hrline/man.gif
效果2 就发现 里面的没有排序
static/image/hrline/man.gif
写的逻辑代码
static/image/hrline/man.gif
<?php return array (
0 =>
array (
'id' => 15,
'name' => '网站设置1',
'rank' => 12,
'children' =>
array (
0 =>
array (
'id' => 16,
'name' => '网站设置',
'rank' => 2,
'children' =>
array (
0 =>
array (
'id' => 18,
'name' => '站点菜单',
'rank' => 0,
),
1 =>
array (
'id' => 17,
'name' => '站点设置',
'rank' => 0,
),
),
),
1 =>
array (
'id' => 19,
'name' => '管理人员',
'rank' => 20,
'children' =>
array (
0 =>
array (
'id' => 20,
'name' => '管理员列表',
'rank' => 0,
),
1 =>
array (
'id' => 26,
'name' => '权限组',
'rank' => 0,
),
2 =>
array (
'id' => 27,
'name' => '规则组',
'rank' => 0,
),
),
),
),
),
1 =>
array (
'id' => 21,
'name' => '博客',
'rank' => 120,
'children' =>
array (
0 =>
array (
'id' => 22,
'name' => '所有文章',
'rank' => 90,
),
1 =>
array (
'id' => 23,
'name' => '评论管理',
'rank' => 100,
),
2 =>
array (
'id' => 24,
'name' => '标签管理',
'rank' => 0,
),
3 =>
array (
'id' => 25,
'name' => '导航栏',
'rank' => 10,
),
),
),
);
要排序的数组,
自己的算法不好,看了好久,没看到什么地方出错,但是就是里面没有排序,好奇怪, 那位大大 help me too 一下...{:5_99:}
python只要用1行代码就够了
页:
[1]