original_string: private function sort_exported_posts(array $posts, array $exportedposts) {
          $postindexes = [];
          foreach (array_values($posts) as $index => $post) {
              $postindexes[$post->get_id()] = $index;
          }
  
          $sortedexportedposts = [];
  
          foreach ($exportedposts as $exportedpost) {
              $index = $postindexes[$exportedpost->id];
              $sortedexportedposts[$index] = $exportedpost;
          }
  
          return $sortedexportedposts;
      }
code: private function sort_exported_posts(array $posts, array $exportedposts) {
          $postindexes = [];
          foreach (array_values($posts) as $index => $post) {
              $postindexes[$post->get_id()] = $index;
          }
  
          $sortedexportedposts = [];
  
          foreach ($exportedposts as $exportedpost) {
              $index = $postindexes[$exportedpost->id];
              $sortedexportedposts[$index] = $exportedpost;
          }
  
          return $sortedexportedposts;
      }
code_tokens: private function sort_exported_posts ( array $ posts , array $ exportedposts ) { $ postindexes = [ ] ; foreach ( array_values ( $ posts ) as $ index => $ post ) { $ postindexes [ $ post -> get_id ( ) ] = $ index ; } $ sortedexportedposts = [ ] ; foreach ( $ exportedposts as $ exportedpost ) { $ index = $ postindexes [ $ exportedpost -> id ] ; $ sortedexportedposts [ $ index ] = $ exportedpost ; } return $ sortedexportedposts ; }
docstring: Sort the list of exported posts back into the same order as the given posts.
  The ordering of the exported posts can often deviate from the given posts due
  to the process of exporting them so we need to sort them back into the order
  that the calling code expected.
  
  @param post_entity[] $posts The posts in the expected order.
  @param stdClass[] $exportedposts The list of exported posts in any order.
  @return stdClass[] Sorted exported posts.
docstring_tokens: Sort the list of exported posts back into the same order as the given posts . The ordering of the exported posts can often deviate from the given posts due to the process of exporting them so we need to sort them back into the order that the calling code expected .