From 820ce7b6f859738059c8fcb2c39e5dea6c688724 Mon Sep 17 00:00:00 2001 From: Sweta Kumari Date: Tue, 15 Sep 2026 02:43:32 +0530 Subject: [PATCH] test: verify insertion sort modifies input collection --- sorts/insertion_sort.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sorts/insertion_sort.py b/sorts/insertion_sort.py index 24f53b654439..e339e5062a27 100644 --- a/sorts/insertion_sort.py +++ b/sorts/insertion_sort.py @@ -50,6 +50,12 @@ def insertion_sort[T: Comparable](collection: MutableSequence[T]) -> MutableSequ True >>> insertion_sort(['d', 'a', 'b', 'e', 'c']) == sorted(['d', 'a', 'b', 'e', 'c']) True + >>> values = [4, 2, 7, 1] + >>> result = insertion_sort(values) + >>> result is values + True + >>> values + [1, 2, 4, 7] >>> import random >>> collection = random.sample(range(-50, 50), 100) >>> insertion_sort(collection) == sorted(collection)