我有这样的数组数据。
[0] => Array (
[id] => 1
[id_requestor] => 1
[jam_input] => 2015-06-20 06:00:00
[jam_pakai] => 2015-06-28 08:00:00
[total_poin] => 30
)
[1] => Array (
[id] => 2
[id_requestor] => 2
[jam_input] => 2015-06-20 07:00:00
[jam_pakai] => 2015-06-28 08:00:00
[total_poin] => 10
)
[2] => Array (
[id] => 3
[id_requestor] => 3
[jam_input] => 2015-06-20 06:30:00
[jam_pakai] => 2015-06-28 08:00:00
[total_poin] => 5
)
在上述数据中,有total_poin
。我后来使用的这个total_poin
。
我想排序total_poin
数组降序。
但我不会使用PHP内置的数组函数。
因为我必须使用像这样的研究论文中的方法。
for i=0 to i<main queue.size
if jobi+1 length > jobi length then
add jobi+1 in front of job i in the queue
end if
if main queue.size = 0 then
add job i last in the main queue
end if
这是我的实施:
function LJFAlgorithm($time_str) {
$batchData = getBatch($time_str);
$ljf = [];
for ($i=0; $i < count($batchData)-1; $i++) {
echo $batchData[$i+1]['total_poin'] ." >= ". $batchData[$i]['total_poin'] . " = " . ($batchData[$i+1]['total_poin'] >= $batchData[$i]['total_poin']);
if ($batchData[$i+1]['total_poin'] >= $batchData[$i]['total_poin']) {
echo ", Add " . $batchData[$i+1]['total_poin'] . " in front of " . $batchData[$i]['total_poin'];
} else {
echo ", Add " . $batchData[$i]['total_poin'] . " in front of " . $batchData[$i+1]['total_poin'];
}
echo '<br/>';
}
print_r($ljf);
}
但它不能很好地工作,我得到一个数据丢失。 这是我的输出代码:
10 >= 30 = , Add 30 in front of 10
5 >= 10 = , Add 10 in front of 5
数组中未添加 5
值。
如何解决?
非常感谢。
答案 0 :(得分:0)
试试这个
Process[] p = Process.GetProcessesByName("notepad");