protected function fixOrder( $order ) {
		$fixed = [];
		$fm = [];
		foreach ( $order as $post_id => $val ) {
			if ( $val['post_type'] === 'front-matter' ) {
				$type = $this->taxonomy->getFrontMatterType( $post_id );
				if ( ! in_array( $type, [ 'before-title', 'title-page', 'dedication', 'epigraph' ], true ) ) {
					// Add front matter that isn't being reorderd without intervention.
					$fixed[ $post_id ] = $val;
				} else {
					// Add front matter that is being reordered to temporary array.
					$fm[ $post_id ] = array_merge( $val, [ 'type' => $type ] );
				}
			} else {
				// Add parts, chapters, and back matter without intervention.
				$fixed[ $post_id ] = $val;
			}
		}
		// Work our way backwards, starting with epigraph
		foreach ( [ 'epigraph', 'dedication', 'title-page', 'before-title' ] as $type ) {
			foreach ( $fm as $post_id => $val ) {
				if ( $val['type'] === $type ) {
					$fixed = [ $post_id => $val ] + $fixed;
					break;
				}
			}
		}
		return $fixed;
	}
protected function fixOrder( $order ) {
		$fixed = [];
		$fm = [];
		foreach ( $order as $post_id => $val ) {
			if ( $val['post_type'] === 'front-matter' ) {
				$type = $this->taxonomy->getFrontMatterType( $post_id );
				if ( ! in_array( $type, [ 'before-title', 'title-page', 'dedication', 'epigraph' ], true ) ) {
					// Add front matter that isn't being reorderd without intervention.
					$fixed[ $post_id ] = $val;
				} else {
					// Add front matter that is being reordered to temporary array.
					$fm[ $post_id ] = array_merge( $val, [ 'type' => $type ] );
				}
			} else {
				// Add parts, chapters, and back matter without intervention.
				$fixed[ $post_id ] = $val;
			}
		}
		// Work our way backwards, starting with epigraph
		foreach ( [ 'epigraph', 'dedication', 'title-page', 'before-title' ] as $type ) {
			foreach ( $fm as $post_id => $val ) {
				if ( $val['type'] === $type ) {
					$fixed = [ $post_id => $val ] + $fixed;
					break;
				}
			}
		}
		return $fixed;
	}
protected function fixOrder ( $ order ) { $ fixed = [ ] ; $ fm = [ ] ; foreach ( $ order as $ post_id => $ val ) { if ( $ val [ 'post_type' ] === 'front-matter' ) { $ type = $ this -> taxonomy -> getFrontMatterType ( $ post_id ) ; if ( ! in_array ( $ type , [ 'before-title' , 'title-page' , 'dedication' , 'epigraph' ] , true ) ) { // Add front matter that isn't being reorderd without intervention. $ fixed [ $ post_id ] = $ val ; } else { // Add front matter that is being reordered to temporary array. $ fm [ $ post_id ] = array_merge ( $ val , [ 'type' => $ type ] ) ; } } else { // Add parts, chapters, and back matter without intervention. $ fixed [ $ post_id ] = $ val ; } } // Work our way backwards, starting with epigraph foreach ( [ 'epigraph' , 'dedication' , 'title-page' , 'before-title' ] as $ type ) { foreach ( $ fm as $ post_id => $ val ) { if ( $ val [ 'type' ] === $ type ) { $ fixed = [ $ post_id => $ val ] + $ fixed ; break ; } } } return $ fixed ; }
Reorder the book structure to conform to Chicago Style, so that the
book begins with Before Title, Title Page, Dedication, Epigraph.

@param array $order
@return array
Reorder the book structure to conform to Chicago Style so that the book begins with Before Title Title Page Dedication Epigraph .