/** @license MIT | @cube-dev/ui-kit v0.147.0 | Cube Dev Team */
//#region src/components/layout/Board/grid-core/sort.ts
/**
* Sort layout items based on the compaction type.
*
* - Vertical compaction: sort by row (y) then column (x)
* - Horizontal compaction: sort by column (x) then row (y)
* - No compaction (null): return original order
*/
function sortLayoutItems(layout, compactType) {
	if (compactType === "horizontal") return sortLayoutItemsByColRow(layout);
	if (compactType === "vertical") return sortLayoutItemsByRowCol(layout);
	if (compactType === "wrap") return sortLayoutItemsByRowCol(layout);
	return [...layout];
}
/**
* Sort layout items by row ascending, then column ascending.
*/
function sortLayoutItemsByRowCol(layout) {
	return [...layout].sort((a, b) => {
		if (a.y !== b.y) return a.y - b.y;
		return a.x - b.x;
	});
}
/**
* Sort layout items by column ascending, then row ascending.
*/
function sortLayoutItemsByColRow(layout) {
	return [...layout].sort((a, b) => {
		if (a.x !== b.x) return a.x - b.x;
		return a.y - b.y;
	});
}

//#endregion
export { sortLayoutItems, sortLayoutItemsByColRow, sortLayoutItemsByRowCol };
//# sourceMappingURL=sort.js.map