From e5de6be24e7668ef7783e05e6abe2167202ac5ca Mon Sep 17 00:00:00 2001 From: c Date: Thu, 29 Aug 2024 12:32:43 +0200 Subject: [PATCH] fix: sort cells by (row, col) to ensure row_end - row_start >= 0 --- src/lib.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 6354079..cdd8118 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -461,7 +461,8 @@ impl Range { /// /// panics when a `Cell` row is lower than the first `Cell` row or /// bigger than the last `Cell` row. - pub fn from_sparse(cells: Vec>) -> Range { + pub fn from_sparse(mut cells: Vec>) -> Range { + cells.sort_by_key(|cell| (cell.pos.0, cell.pos.1)); if cells.is_empty() { Range::empty() } else {