pub fn sort_layout_boxes(
elements: &[LayoutBox],
image_width: f32,
) -> Vec<LayoutBox>Expand description
Sort layout boxes in reading order with column detection.
This function sorts layout boxes from top to bottom, left to right, with special handling for two-column layouts. Boxes are first sorted by y-coordinate, then separated into left and right columns based on their x-coordinate.
The algorithm:
- Sort boxes by (y, x) coordinates
- Identify left column boxes (x1 < w/4 and x2 < 3w/5)
- Identify right column boxes (x1 > 2w/5)
- Other boxes are considered full-width
- Within each column, sort by y-coordinate
This follows standard layout sorting implementation.
§Arguments
elements- Slice of layout boxes to sortimage_width- Width of the image for column detection
§Returns
A vector of sorted layout boxes