+namespace {
+
+bool SortVertically(Component* lhs, Component* rhs)
+{
+ auto leftRect = lhs->GetExtents(CoordType::WINDOW);
+ auto rightRect = rhs->GetExtents(CoordType::WINDOW);
+
+ return leftRect.y < rightRect.y;
+}
+
+bool SortHorizontally(Component* lhs, Component* rhs)
+{
+ auto leftRect = lhs->GetExtents(CoordType::WINDOW);
+ auto rightRect = rhs->GetExtents(CoordType::WINDOW);
+
+ return leftRect.x < rightRect.x;
+}
+
+std::vector<std::vector<Component*>> SplitLines(const std::vector<Component*>& children)
+{
+ // Find first with non-zero area
+ auto first = std::find_if(children.begin(), children.end(), [](Component* component) -> bool {
+ auto extents = component->GetExtents(CoordType::WINDOW);
+ return extents.height != 0.0f && extents.width != 0.0f;
+ });
+
+ if(first == children.end())
+ {
+ return {};
+ }
+
+ std::vector<std::vector<Component*>> lines(1);
+ Dali::Rect<> lineRect = (*first)->GetExtents(CoordType::WINDOW);
+ Dali::Rect<> rect;
+
+ // Split into lines
+ for(auto it = first; it != children.end(); ++it)
+ {
+ auto child = *it;
+
+ rect = child->GetExtents(CoordType::WINDOW);
+ if(rect.height == 0.0f || rect.width == 0.0f)
+ {
+ // Zero area, ignore
+ continue;
+ }
+
+ if(lineRect.y + (0.25 * lineRect.height) >= rect.y)
+ {
+ // Same line
+ lines.back().push_back(child);
+ }
+ else
+ {
+ // Start a new line
+ lineRect = rect;
+ lines.emplace_back();
+ lines.back().push_back(child);
+ }
+ }
+
+ return lines;
+}
+
+} // anonymous namespace
+