PHPカスタム順序による多次元配列 -- php フィールド と arrays フィールド と sorting フィールド と multidimensional-array フィールド 関連 問題

php sort multidimentional array by custom order












2
vote

問題

日本語

多次元配列の鍵価値(ASCまたはDESC)の一方で、何度も尋ねられます。 しかし、私の問題に対する解決策は、事前定義されたカスタム順序でそのキー値の1つによって多次元配列をソートしなければならない問題の解決策を見つけませんでした。

の配列を取ります <事前> <コード> [2018-06-08 09:44:54,185] ERROR Error while renaming dir for foo-0 in log dir C:confluent-4.1.1datakafka (kafka.server.LogDirFailureChannel) java.nio.file.AccessDeniedException: C:confluent-4.1.1datakafkafoo-0 -> C:confluent-4.1.1datakafkafoo-0.cf697a92ed5246c0977bf9a279f15de8-delete at sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:83) at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:97) at sun.nio.fs.WindowsFileCopy.move(WindowsFileCopy.java:387) at sun.nio.fs.WindowsFileSystemProvider.move(WindowsFileSystemProvider.java:287) at java.nio.file.Files.move(Files.java:1395) at org.apache.kafka.common.utils.Utils.atomicMoveWithFallback(Utils.java:697) at kafka.log.Log$$anonfun$renameDir$1.apply$mcV$sp(Log.scala:579) at kafka.log.Log$$anonfun$renameDir$1.apply(Log.scala:577) at kafka.log.Log$$anonfun$renameDir$1.apply(Log.scala:577) at kafka.log.Log.maybeHandleIOException(Log.scala:1678) at kafka.log.Log.renameDir(Log.scala:577) at kafka.log.LogManager.asyncDelete(LogManager.scala:828) at kafka.cluster.Partition$$anonfun$delete$1.apply(Partition.scala:240) at kafka.cluster.Partition$$anonfun$delete$1.apply(Partition.scala:235) at kafka.utils.CoreUtils$.inLock(CoreUtils.scala:250) at kafka.utils.CoreUtils$.inWriteLock(CoreUtils.scala:258) at kafka.cluster.Partition.delete(Partition.scala:235) at kafka.server.ReplicaManager.stopReplica(ReplicaManager.scala:347) at kafka.server.ReplicaManager$$anonfun$stopReplicas$2.apply(ReplicaManager.scala:377) at kafka.server.ReplicaManager$$anonfun$stopReplicas$2.apply(ReplicaManager.scala:375) at scala.collection.Iterator$class.foreach(Iterator.scala:891) at scala.collection.AbstractIterator.foreach(Iterator.scala:1334) at scala.collection.IterableLike$class.foreach(IterableLike.scala:72) at scala.collection.AbstractIterable.foreach(Iterable.scala:54) at kafka.server.ReplicaManager.stopReplicas(ReplicaManager.scala:375) at kafka.server.KafkaApis.handleStopReplicaRequest(KafkaApis.scala:205) at kafka.server.KafkaApis.handle(KafkaApis.scala:116) at kafka.server.KafkaRequestHandler.run(KafkaRequestHandler.scala:69) at java.lang.Thread.run(Thread.java:748) Suppressed: java.nio.file.AccessDeniedException: C:confluent-4.1.1datakafkafoo-0 -> C:confluent-4.1.1datakafkafoo-0.cf697a92ed5246c0977bf9a279f15de8-delete at sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:83) at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:97) at sun.nio.fs.WindowsFileCopy.move(WindowsFileCopy.java:301) at sun.nio.fs.WindowsFileSystemProvider.move(WindowsFileSystemProvider.java:287) at java.nio.file.Files.move(Files.java:1395) at org.apache.kafka.common.utils.Utils.atomicMoveWithFallback(Utils.java:694) ... 23 more [2018-06-08 09:44:54,187] INFO [ReplicaManager broker=0] Stopping serving replicas in dir C:confluent-4.1.1datakafka (kafka.server.ReplicaManager) [2018-06-08 09:44:54,192] INFO [ReplicaFetcherManager on broker 0] Removed fetcher for partitions (kafka.server.ReplicaFetcherManager) [2018-06-08 09:44:54,193] INFO [ReplicaAlterLogDirsManager on broker 0] Removed fetcher for partitions (kafka.server.ReplicaAlterLogDirsManager) [2018-06-08 09:44:54,195] INFO [ReplicaManager broker=0] Broker 0 stopped fetcher for partitions and stopped moving logs for partitions because they are in the failed log directory C:confluent-4.1.1datakafka. (kafka.server.ReplicaManager) [2018-06-08 09:44:54,195] INFO Stopping serving logs in dir C:confluent-4.1.1datakafka (kafka.log.LogManager) [2018-06-08 09:44:54,197] ERROR Shutdown broker because all log dirs in C:confluent-4.1.1datakafka have failed (kafka.log.LogManager) [2018-06-08 09:44:54,198] INFO [ReplicaFetcherManager on broker 0] Removed fetcher for partitions (kafka.server.ReplicaFetcherManager) 1

および下の配列で定義された順序でサブキー 'ID'でこの配列をソートする:

<事前> <コード> [2018-06-08 09:44:54,185] ERROR Error while renaming dir for foo-0 in log dir C:confluent-4.1.1datakafka (kafka.server.LogDirFailureChannel) java.nio.file.AccessDeniedException: C:confluent-4.1.1datakafkafoo-0 -> C:confluent-4.1.1datakafkafoo-0.cf697a92ed5246c0977bf9a279f15de8-delete at sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:83) at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:97) at sun.nio.fs.WindowsFileCopy.move(WindowsFileCopy.java:387) at sun.nio.fs.WindowsFileSystemProvider.move(WindowsFileSystemProvider.java:287) at java.nio.file.Files.move(Files.java:1395) at org.apache.kafka.common.utils.Utils.atomicMoveWithFallback(Utils.java:697) at kafka.log.Log$$anonfun$renameDir$1.apply$mcV$sp(Log.scala:579) at kafka.log.Log$$anonfun$renameDir$1.apply(Log.scala:577) at kafka.log.Log$$anonfun$renameDir$1.apply(Log.scala:577) at kafka.log.Log.maybeHandleIOException(Log.scala:1678) at kafka.log.Log.renameDir(Log.scala:577) at kafka.log.LogManager.asyncDelete(LogManager.scala:828) at kafka.cluster.Partition$$anonfun$delete$1.apply(Partition.scala:240) at kafka.cluster.Partition$$anonfun$delete$1.apply(Partition.scala:235) at kafka.utils.CoreUtils$.inLock(CoreUtils.scala:250) at kafka.utils.CoreUtils$.inWriteLock(CoreUtils.scala:258) at kafka.cluster.Partition.delete(Partition.scala:235) at kafka.server.ReplicaManager.stopReplica(ReplicaManager.scala:347) at kafka.server.ReplicaManager$$anonfun$stopReplicas$2.apply(ReplicaManager.scala:377) at kafka.server.ReplicaManager$$anonfun$stopReplicas$2.apply(ReplicaManager.scala:375) at scala.collection.Iterator$class.foreach(Iterator.scala:891) at scala.collection.AbstractIterator.foreach(Iterator.scala:1334) at scala.collection.IterableLike$class.foreach(IterableLike.scala:72) at scala.collection.AbstractIterable.foreach(Iterable.scala:54) at kafka.server.ReplicaManager.stopReplicas(ReplicaManager.scala:375) at kafka.server.KafkaApis.handleStopReplicaRequest(KafkaApis.scala:205) at kafka.server.KafkaApis.handle(KafkaApis.scala:116) at kafka.server.KafkaRequestHandler.run(KafkaRequestHandler.scala:69) at java.lang.Thread.run(Thread.java:748) Suppressed: java.nio.file.AccessDeniedException: C:confluent-4.1.1datakafkafoo-0 -> C:confluent-4.1.1datakafkafoo-0.cf697a92ed5246c0977bf9a279f15de8-delete at sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:83) at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:97) at sun.nio.fs.WindowsFileCopy.move(WindowsFileCopy.java:301) at sun.nio.fs.WindowsFileSystemProvider.move(WindowsFileSystemProvider.java:287) at java.nio.file.Files.move(Files.java:1395) at org.apache.kafka.common.utils.Utils.atomicMoveWithFallback(Utils.java:694) ... 23 more [2018-06-08 09:44:54,187] INFO [ReplicaManager broker=0] Stopping serving replicas in dir C:confluent-4.1.1datakafka (kafka.server.ReplicaManager) [2018-06-08 09:44:54,192] INFO [ReplicaFetcherManager on broker 0] Removed fetcher for partitions (kafka.server.ReplicaFetcherManager) [2018-06-08 09:44:54,193] INFO [ReplicaAlterLogDirsManager on broker 0] Removed fetcher for partitions (kafka.server.ReplicaAlterLogDirsManager) [2018-06-08 09:44:54,195] INFO [ReplicaManager broker=0] Broker 0 stopped fetcher for partitions and stopped moving logs for partitions because they are in the failed log directory C:confluent-4.1.1datakafka. (kafka.server.ReplicaManager) [2018-06-08 09:44:54,195] INFO Stopping serving logs in dir C:confluent-4.1.1datakafka (kafka.log.LogManager) [2018-06-08 09:44:54,197] ERROR Shutdown broker because all log dirs in C:confluent-4.1.1datakafka have failed (kafka.log.LogManager) [2018-06-08 09:44:54,198] INFO [ReplicaFetcherManager on broker 0] Removed fetcher for partitions (kafka.server.ReplicaFetcherManager) 2

だから結果は

です <事前> <コード> [2018-06-08 09:44:54,185] ERROR Error while renaming dir for foo-0 in log dir C:confluent-4.1.1datakafka (kafka.server.LogDirFailureChannel) java.nio.file.AccessDeniedException: C:confluent-4.1.1datakafkafoo-0 -> C:confluent-4.1.1datakafkafoo-0.cf697a92ed5246c0977bf9a279f15de8-delete at sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:83) at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:97) at sun.nio.fs.WindowsFileCopy.move(WindowsFileCopy.java:387) at sun.nio.fs.WindowsFileSystemProvider.move(WindowsFileSystemProvider.java:287) at java.nio.file.Files.move(Files.java:1395) at org.apache.kafka.common.utils.Utils.atomicMoveWithFallback(Utils.java:697) at kafka.log.Log$$anonfun$renameDir$1.apply$mcV$sp(Log.scala:579) at kafka.log.Log$$anonfun$renameDir$1.apply(Log.scala:577) at kafka.log.Log$$anonfun$renameDir$1.apply(Log.scala:577) at kafka.log.Log.maybeHandleIOException(Log.scala:1678) at kafka.log.Log.renameDir(Log.scala:577) at kafka.log.LogManager.asyncDelete(LogManager.scala:828) at kafka.cluster.Partition$$anonfun$delete$1.apply(Partition.scala:240) at kafka.cluster.Partition$$anonfun$delete$1.apply(Partition.scala:235) at kafka.utils.CoreUtils$.inLock(CoreUtils.scala:250) at kafka.utils.CoreUtils$.inWriteLock(CoreUtils.scala:258) at kafka.cluster.Partition.delete(Partition.scala:235) at kafka.server.ReplicaManager.stopReplica(ReplicaManager.scala:347) at kafka.server.ReplicaManager$$anonfun$stopReplicas$2.apply(ReplicaManager.scala:377) at kafka.server.ReplicaManager$$anonfun$stopReplicas$2.apply(ReplicaManager.scala:375) at scala.collection.Iterator$class.foreach(Iterator.scala:891) at scala.collection.AbstractIterator.foreach(Iterator.scala:1334) at scala.collection.IterableLike$class.foreach(IterableLike.scala:72) at scala.collection.AbstractIterable.foreach(Iterable.scala:54) at kafka.server.ReplicaManager.stopReplicas(ReplicaManager.scala:375) at kafka.server.KafkaApis.handleStopReplicaRequest(KafkaApis.scala:205) at kafka.server.KafkaApis.handle(KafkaApis.scala:116) at kafka.server.KafkaRequestHandler.run(KafkaRequestHandler.scala:69) at java.lang.Thread.run(Thread.java:748) Suppressed: java.nio.file.AccessDeniedException: C:confluent-4.1.1datakafkafoo-0 -> C:confluent-4.1.1datakafkafoo-0.cf697a92ed5246c0977bf9a279f15de8-delete at sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:83) at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:97) at sun.nio.fs.WindowsFileCopy.move(WindowsFileCopy.java:301) at sun.nio.fs.WindowsFileSystemProvider.move(WindowsFileSystemProvider.java:287) at java.nio.file.Files.move(Files.java:1395) at org.apache.kafka.common.utils.Utils.atomicMoveWithFallback(Utils.java:694) ... 23 more [2018-06-08 09:44:54,187] INFO [ReplicaManager broker=0] Stopping serving replicas in dir C:confluent-4.1.1datakafka (kafka.server.ReplicaManager) [2018-06-08 09:44:54,192] INFO [ReplicaFetcherManager on broker 0] Removed fetcher for partitions (kafka.server.ReplicaFetcherManager) [2018-06-08 09:44:54,193] INFO [ReplicaAlterLogDirsManager on broker 0] Removed fetcher for partitions (kafka.server.ReplicaAlterLogDirsManager) [2018-06-08 09:44:54,195] INFO [ReplicaManager broker=0] Broker 0 stopped fetcher for partitions and stopped moving logs for partitions because they are in the failed log directory C:confluent-4.1.1datakafka. (kafka.server.ReplicaManager) [2018-06-08 09:44:54,195] INFO Stopping serving logs in dir C:confluent-4.1.1datakafka (kafka.log.LogManager) [2018-06-08 09:44:54,197] ERROR Shutdown broker because all log dirs in C:confluent-4.1.1datakafka have failed (kafka.log.LogManager) [2018-06-08 09:44:54,198] INFO [ReplicaFetcherManager on broker 0] Removed fetcher for partitions (kafka.server.ReplicaFetcherManager) 3

注:$ SORT_ORDER_IDアレイでは、$ sort_order_id配列でも一部が利用できない場合は、最後に保持してください(上記の例ID 222と200のように$ SORT_ORDER_ID配列は$ SORT_ORDER_ID配列ではありませんので、前には最後にあります。注文)

私はそれのためにアルゴリズムを作成することができませんでした...私はいくつかを助けることを願っています...

英語

Sorting an multidimensional array by one of its key value (asc or desc) is asked too many times. but I've not found any solution for my problem where you have to sort a multidimensional array by one of its key value in predefined custom order.

take an array for example

$array[0] = array('id'=> '111', value=>'abc'); $array[1] = array('id'=> '100', value=>'abc'); $array[2] = array('id'=> '132', value=>'abc'); $array[3] = array('id'=> '222', value=>'abc'); $array[4] = array('id'=> '112', value=>'abc'); $array[5] = array('id'=> '200', value=>'abc'); 

and to sort this array by subkey 'id' by the order defined in array below:

$sort_order_id = array('112','111','132','100'); 

so the result would be

$array[0] = array('id'=> '112', value=>'abc'); $array[1] = array('id'=> '111', value=>'abc'); $array[2] = array('id'=> '132', value=>'abc'); $array[3] = array('id'=> '100', value=>'abc'); $array[4] = array('id'=> '222', value=>'abc'); $array[5] = array('id'=> '200', value=>'abc'); 

NOTE: if some of the id's are not available in $sort_order_id array, keep them in last (like in above example id 222 and 200 are not in $sort_order_id array, so it comes in last as per their previous order)

i tried a lot but unable to create algorithm for that... i hope some one will help me...

</div
           
       
       

回答リスト

5
 
vote
vote
ベストアンサー
 

id

で配列をソートするための標準コードを取ります。 <事前> <コード> usort($data, function($x, $y) { return $x['id'] - $y['id']; });

あなたがやりたいことは、ID自身ではなく、むしろ各IDの「重み」(IDを入れる任意の順序を表す)によって並べ替えられます。そのため、キーがIDの場合はアレイを作成し、値は重み付け、IDを重みに変換するために使用します。

<事前> <コード> // array_flip turns 0 => 112, 1 => 111, ... into 122 => 0, 111 => 1, ... $weights = array_flip(array('112','111','132','100')); usort($data, function($x, $y) use($weights) { return $weights[$x['id']] - $weights[$y['id']]; });

更新:指定された重みを持たないIDを処理したいので、上記をさらに拡大する必要があります。

<事前> <コード> usort($data, function($x, $y) use($weights) { if (!isset($weights[$x['id']], $weights[$y['id']])) { // none of the ids have weight, so sort by bare id return $x['id'] - $y['id']; } else if (!isset($weights[$x['id']])) { // x does not have weight, put it last return 1; } else if (!isset($weights[$y['id']])) { // y does not have weight, put it last return -1; } // both have weights, use them return $weights[$x['id']] - $weights[$y['id']]; });
 

Take the standard code for sorting an array by id:

usort($data, function($x, $y) { return $x['id'] - $y['id']; }); 

What you want to do is sort not by the ids themselves, but rather by the "weight" of each id (which represents the arbitrary order you want the ids to be put in). So make an array where keys are ids and values are the weights and use it to convert ids to weights:

// array_flip turns 0 => 112, 1 => 111, ... into 122 => 0, 111 => 1, ... $weights = array_flip(array('112','111','132','100'));  usort($data, function($x, $y) use($weights) {     return $weights[$x['id']] - $weights[$y['id']]; }); 

Update: Since you also want to handle ids that do not have a specified weight you will have to further expand the above:

usort($data, function($x, $y) use($weights) {     if (!isset($weights[$x['id']], $weights[$y['id']])) {         // none of the ids have weight, so sort by bare id         return $x['id'] - $y['id'];     }     else if (!isset($weights[$x['id']])) {          // x does not have weight, put it last         return 1;     }     else if (!isset($weights[$y['id']])) {         // y does not have weight, put it last         return -1;     }      // both have weights, use them     return $weights[$x['id']] - $weights[$y['id']]; }); 
</div
 
 
 
 
1
 
vote

@ Jonの答えは、宇宙船演算子とヌルの合体とはるかに簡潔になる可能性があります。

反転すると、ID注文配列が便利な検索になります。 指定された行のID値が順序付け配列に見つからない場合は、出力配列の「後で」プッシュされます。

コード:(デモ)

<事前> <コード> $array = [ ['id' => '111', 'value' => 'abc'], ['id' => '100', 'value' => 'abc'], ['id' => '132', 'value' => 'abc'], ['id' => '222', 'value' => 'abc'], ['id' => '112', 'value' => 'abc'], ['id' => '200', 'value' => 'abc'] ]; $idPriorities = array_flip(['112', '111', '132', '100']); $idOutlier = count($idPriorities); usort( $array, function($a, $b) use ($idPriorities, $idOutlier) { return ($idPriorities[$a['id']] ?? $idOutlier) <=> ($idPriorities[$b['id']] ?? $idOutlier); } ); var_export($array);

またはPHP7.4 +(デモ)

<事前> <コード> usort( $array, fn($a, $b) => ($idPriorities[$a['id']] ?? $idOutlier) <=> ($idPriorities[$b['id']] ?? $idOutlier) );
 

@Jon's answer can be much more concise with the spaceship operator and null coalescing.

The id ordering array becomes a convenience lookup once it is flipped. If a given row's id value is not found in the ordering array, then it is pushed "later" in the output array.

Code: (Demo)

$array = [     ['id' => '111', 'value' => 'abc'],     ['id' => '100', 'value' => 'abc'],     ['id' => '132', 'value' => 'abc'],     ['id' => '222', 'value' => 'abc'],     ['id' => '112', 'value' => 'abc'],     ['id' => '200', 'value' => 'abc'] ];  $idPriorities = array_flip(['112', '111', '132', '100']); $idOutlier = count($idPriorities);  usort(     $array,     function($a, $b) use ($idPriorities, $idOutlier) {         return ($idPriorities[$a['id']] ?? $idOutlier) <=> ($idPriorities[$b['id']] ?? $idOutlier);     } );  var_export($array); 

or with PHP7.4+ (Demo)

usort(     $array,     fn($a, $b) => ($idPriorities[$a['id']] ?? $idOutlier) <=> ($idPriorities[$b['id']] ?? $idOutlier) ); 
</div
 
 
0
 
vote

usort() が必要です。これにより、オーダーメイドの要件で並べ替えることができます。あなたの場合は、<コード> sort_order_id Array内のIDの位置によって並べ替える必要があります。

<事前> <コード> $array = array( array('id'=> '111', value=>'abc'), array('id'=> '100', value=>'abc'), array('id'=> '132', value=>'abc'), array('id'=> '112', value=>'abc') ); $sort_order_id = array('112','111','132','100'); usort($array, function($a, $b) { global $sort_order_id; return array_search($a['id'], $sort_order_id) - array_search($b['id'], $sort_order_id); });
 

You need usort(), which allows you to sort by bespoke requirements. In your case, you need to sort by the ID's position within your sort_order_id array.

$array = array(     array('id'=> '111', value=>'abc'),     array('id'=> '100', value=>'abc'),     array('id'=> '132', value=>'abc'),     array('id'=> '112', value=>'abc') ); $sort_order_id = array('112','111','132','100'); usort($array, function($a, $b) {     global $sort_order_id;     return array_search($a['id'], $sort_order_id) - array_search($b['id'], $sort_order_id); }); 
</div
 
 
 
 
0
 
vote

これを試してみてください

<事前> <コード> echo "<pre>"; $array[0] = array('id'=> '111', 'value'=>'abc'); $array[1] = array('id'=> '100', 'value'=>'abc'); $array[2] = array('id'=> '132', 'value'=>'abc'); $array[3] = array('id'=> '222', 'value'=>'abc'); $array[4] = array('id'=> '112', 'value'=>'abc'); $array[5] = array('id'=> '200', 'value'=>'abc'); $arr_temp = $array; $array = array(); $sort_order_id = array('112','111','132','100'); foreach($sort_order_id as $order_id) { foreach($arr_temp as $key=>$arr) { if($arr['id'] == $order_id) { $array[] = $arr; unset($arr_temp[$key]); } } } foreach($arr_temp as $key=>$arr) { $array[] = $arr; unset($arr_temp[$key]); } print_r($array);

出力:

<事前> <コード> usort($data, function($x, $y) { return $x['id'] - $y['id']; }); 0
 

try this one

echo "<pre>";  $array[0] = array('id'=> '111', 'value'=>'abc'); $array[1] = array('id'=> '100', 'value'=>'abc'); $array[2] = array('id'=> '132', 'value'=>'abc'); $array[3] = array('id'=> '222', 'value'=>'abc'); $array[4] = array('id'=> '112', 'value'=>'abc'); $array[5] = array('id'=> '200', 'value'=>'abc');  $arr_temp = $array; $array = array(); $sort_order_id = array('112','111','132','100'); foreach($sort_order_id as $order_id) {     foreach($arr_temp as $key=>$arr)     {         if($arr['id'] == $order_id)         {             $array[] = $arr;             unset($arr_temp[$key]);         }     } }  foreach($arr_temp as $key=>$arr) {         $array[] = $arr;         unset($arr_temp[$key]); }  print_r($array); 

OUTPUT :

Array (     [0] => Array         (             [id] => 112             [value] => abc         )      [1] => Array         (             [id] => 111             [value] => abc         )      [2] => Array         (             [id] => 132             [value] => abc         )      [3] => Array         (             [id] => 100             [value] => abc         )      [4] => Array         (             [id] => 222             [value] => abc         )      [5] => Array         (             [id] => 200             [value] => abc         )  ) 
</div
 
 
 
 

関連する質問

9  STD :: Valarrayを使用して、隣接する2D配列を保存/操作できますか?  ( How can i use a stdvalarray to store manipulate a contiguous 2d array ) 
std::valarray を使用して2Dアレイを保存/操作する方法は? 行/列インデックスでアクセスされる要素を持つ2D配列の例を見たいです。この疑似コードのようなもの: <事前> <コード> matrix(i,j) = 42; そのような配列を初期...

2  C ++ 3次元CHAR配列を使用して渡す方法  ( C how to use and pass a 3 dimensional char array ) 
関数の戻り値を保存するためのCHAR配列を構築しようとしています。以下の関数では、データは***** valv **に格納されています。データにアクセスするための外部変数を構築する方法 <事前> <コード> int credis_lrange(REDIS rh...

-1  Javaでの多次元配列の並べ替え[閉じた]  ( Sorting multidimensional array in java ) 
ここで尋ねられていることを知るのは難しいです。この問題はあいまい、曖昧で、不完全で、過度に広く、または修辞的であり、現在の形で合理的に回答することはできません。再開できるようにこの質問を...

1  Shape(N、)のNDアレイのNDArrayから特定の要素を取得する  ( Get specific elements from ndarray of ndarrays with shape n ) 
NDARRAY: <事前> <コード> A = np.array([np.array([1], dtype='f'), np.array([2, 3], dtype='f'), np.array([...

3  Pythonで保存されている単純なデータ  ( Simple data storing in python ) 
各行が簡単に解析できる配列の文字列表現であるように、Pythonを使用してデータを格納するための単純なソリューションを探しています。 私はそのような仕事を簡単にするための図書館を持っているのは確かに私が見つけたすべてのアプローチがそれを仕事にするのにずさんだっ...

11  3次元配列のすべての値をJavaでゼロに設定するための最良の方法は何ですか?  ( Whats the best way to set all values of a three dimensional array to zero in ja ) 
私はゼロにリセットしたい3次元配列を持っています。これを行う簡単な方法は、3つの RuntimeException6 Loops:を含まないようです。 <事前> <コード> RuntimeException7 ...

2  PHP - 区切られた文字列から多次元連想配列を作成する  ( Php make multi dimensional associative array from a delimited string ) 
この文字列を回すことができます: <事前> <コード> "package.deal.category" このような配列に: <事前> <コード> $array['package']['deal']['category'] この時点でインデックス内の値は...

0  異なるデータ型を2Dアレイに分離するには.split関数を使用しますか?  ( How would i use the split function to separate different data types into 2d arr ) 
私はこのようないくつかの行を持つ.txtファイルを持っています: <コード> Robot 1923 human M 12M Star Gaze, 73, 1543, B, Joseph Smith <コード> Sanction 1932 indigo ...

12  多次元配列の要素から最大値を取得しますか?  ( Get the maximum value from an element in a multidimensional array ) 
多次元配列の特定のキーの最大値を選択しようとしています。私は問題の鍵を「入手」... だから、アレイ(ここではここで投稿しているものよりはるかに長い) <事前> <コード> [0] => stdClass Object ( [id] ...

3  プログラム出力に関する問題  ( Problem with program output ) 
下記P>は、私のプログラムと、決定要因に問題があるIMです。 ファイル入力は: <事前> <コード> 2 1 0 0 1 3 8 9 1 3 5 2 -2 3 -1 0 および2番目の行列の場合、入力ファイル内の行列2の行列関数の結果の結果、コードで何が...




© 2022 cndgn.com All Rights Reserved. Q&Aハウス 全著作権所有