From 7a2e13fb467f4a6d0da129f223fcdb84e54efadc Mon Sep 17 00:00:00 2001 From: oleksandr-maksymikhin Date: Thu, 2 Jan 2025 07:42:37 +0100 Subject: [PATCH 1/9] structure of files created structure of files --- solutions/bubble_sort.py | 0 solutions/tests/test_bubble_sort.py | 0 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 solutions/bubble_sort.py create mode 100644 solutions/tests/test_bubble_sort.py diff --git a/solutions/bubble_sort.py b/solutions/bubble_sort.py new file mode 100644 index 000000000..e69de29bb diff --git a/solutions/tests/test_bubble_sort.py b/solutions/tests/test_bubble_sort.py new file mode 100644 index 000000000..e69de29bb From c025d3fc1c4efcf0996d9852f65217cc4535f04b Mon Sep 17 00:00:00 2001 From: oleksandr-maksymikhin Date: Thu, 2 Jan 2025 08:11:19 +0100 Subject: [PATCH 2/9] completed docstring completed docstring --- solutions/bubble_sort.py | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/solutions/bubble_sort.py b/solutions/bubble_sort.py index e69de29bb..fc4f90a9e 100644 --- a/solutions/bubble_sort.py +++ b/solutions/bubble_sort.py @@ -0,0 +1,38 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +""" +A module for sorting collection using bubble sort algorithm. + +Module contents: + - bubble_sort: sort the collection in ascending order. + +Created on 2024-01-02 +Author: Oleksandr Maksymikhin +""" + + +def bubble_sort(input_collection: list[int]) -> list[int]: + """Sort collection using bubble sort algorithm. + + Collection is a set of the same type data. + Bubble sort is a sorting algorithm that swaps elements moving larger elements to the end of collection. + + Parameters: + input_collection: list[int], collection of unsorted data type int. + + Returns -> list[int], collection of sorted data type int. + + Raises: + AssertionError: if collection contains elements of different type. + + Examples: + >>> bubble_sort(1) + [1] + >>> bubble_sort([1, 3, 2]]) + [1, 2, 3] + >>> bubble_sort([3, 2, 1000000, 1]]) + [1, 2, 3, 1000000] + """ + # add return statement to avoid lint errors + output_collection = input_collection + return output_collection From 70d45ad8b22f53705499a11de071d980ec154a65 Mon Sep 17 00:00:00 2001 From: oleksandr-maksymikhin Date: Thu, 2 Jan 2025 08:17:41 +0100 Subject: [PATCH 3/9] corrected pylint notifications --- solutions/bubble_sort.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/solutions/bubble_sort.py b/solutions/bubble_sort.py index fc4f90a9e..b4089f1e4 100644 --- a/solutions/bubble_sort.py +++ b/solutions/bubble_sort.py @@ -14,8 +14,7 @@ def bubble_sort(input_collection: list[int]) -> list[int]: """Sort collection using bubble sort algorithm. - Collection is a set of the same type data. - Bubble sort is a sorting algorithm that swaps elements moving larger elements to the end of collection. + Sort elements in collection by swapping and moving larger elements to the end of collection. Parameters: input_collection: list[int], collection of unsorted data type int. From 6817f1394b4fc084c1336bf182eebff7ada61e3e Mon Sep 17 00:00:00 2001 From: oleksandr-maksymikhin Date: Fri, 3 Jan 2025 10:04:56 +0100 Subject: [PATCH 4/9] sort collection of type(int) sort collection of type(int) with tests coverage --- solutions/bubble_sort.py | 27 +++++++++++++-- solutions/tests/test_bubble_sort.py | 51 +++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+), 3 deletions(-) diff --git a/solutions/bubble_sort.py b/solutions/bubble_sort.py index b4089f1e4..c88834f61 100644 --- a/solutions/bubble_sort.py +++ b/solutions/bubble_sort.py @@ -11,6 +11,7 @@ """ +# def bubble_sort(input_collection: list[int]) -> list[int]: def bubble_sort(input_collection: list[int]) -> list[int]: """Sort collection using bubble sort algorithm. @@ -32,6 +33,26 @@ def bubble_sort(input_collection: list[int]) -> list[int]: >>> bubble_sort([3, 2, 1000000, 1]]) [1, 2, 3, 1000000] """ - # add return statement to avoid lint errors - output_collection = input_collection - return output_collection + + # copy collection to avoid side effect + collection = input_collection.copy() + # define collection length + collection_length = len(collection) + # first loop to traverse the collection + for current_item_index in range(collection_length): + # flag to break if the last run didn't swap any item + already_sorted = True + # second loop to compare item with adjacent one + for swap_index in range(collection_length - current_item_index - 1): + # swap items if next adjacent item is bigger + if collection[swap_index] > collection[swap_index + 1]: + (collection[swap_index], collection[swap_index + 1]) = ( + collection[swap_index + 1], + collection[swap_index], + ) + already_sorted = False + # break loop if the last run didn't swap any item + if already_sorted: + break + # return sorted collection + return collection diff --git a/solutions/tests/test_bubble_sort.py b/solutions/tests/test_bubble_sort.py index e69de29bb..3ba00b638 100644 --- a/solutions/tests/test_bubble_sort.py +++ b/solutions/tests/test_bubble_sort.py @@ -0,0 +1,51 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +""" +Test module for bubble_sort function. + +Test categories: + - Standard cases: typical lists with different lengths + - Edge cases: empty lists, single element + - Defensive tests: wrong input types, different input types + +Created on 2024-01-03 +Author: Oleksandr Maksymikhin +""" + +import unittest + +from ..bubble_sort import bubble_sort + + +class TestBubbleSort(unittest.TestCase): + """Test the bubble_sort function.""" + + def test_empty_list(self): + """It should return [] for input []""" + actual = bubble_sort([]) + expected = [] + self.assertEqual(actual, expected) + + def test_one_element_list(self): + """It should return [1] for input [1]""" + actual = bubble_sort([1]) + expected = [1] + self.assertEqual(actual, expected) + + def test_two_element_list(self): + """It should return [1, 2] for input [2, 1]""" + actual = bubble_sort([2, 1]) + expected = [1, 2] + self.assertEqual(actual, expected) + + def test_three_elements_list(self): + """It should return [1, 2, 3] for input [3, 2, 1]""" + actual = bubble_sort([3, 2, 1]) + expected = [1, 2, 3] + self.assertEqual(actual, expected) + + def test_four_elements_big_number_list(self): + """It should return [1, 2, 3, 100500] for input [2, 3, 100500, 1]""" + actual = bubble_sort([2, 3, 100500, 1]) + expected = [1, 2, 3, 100500] + self.assertEqual(actual, expected) From daedfbe0ebc226b0b8fbb6636eb08a617936b6ec Mon Sep 17 00:00:00 2001 From: oleksandr-maksymikhin Date: Fri, 3 Jan 2025 10:32:58 +0100 Subject: [PATCH 5/9] extended parameter data types to (int, char, string, bool) Extended parameter data types. Now module works with (int, char, string, bool). Tests cover all data types (int, char, string, bool) --- solutions/bubble_sort.py | 6 ++--- solutions/tests/test_bubble_sort.py | 36 +++++++++++++++++++++++++---- 2 files changed, 34 insertions(+), 8 deletions(-) diff --git a/solutions/bubble_sort.py b/solutions/bubble_sort.py index c88834f61..8d7433af8 100644 --- a/solutions/bubble_sort.py +++ b/solutions/bubble_sort.py @@ -12,7 +12,7 @@ # def bubble_sort(input_collection: list[int]) -> list[int]: -def bubble_sort(input_collection: list[int]) -> list[int]: +def bubble_sort(input_collection: list[any]) -> list[any]: """Sort collection using bubble sort algorithm. Sort elements in collection by swapping and moving larger elements to the end of collection. @@ -33,9 +33,7 @@ def bubble_sort(input_collection: list[int]) -> list[int]: >>> bubble_sort([3, 2, 1000000, 1]]) [1, 2, 3, 1000000] """ - - # copy collection to avoid side effect - collection = input_collection.copy() + collection = input_collection # define collection length collection_length = len(collection) # first loop to traverse the collection diff --git a/solutions/tests/test_bubble_sort.py b/solutions/tests/test_bubble_sort.py index 3ba00b638..2143f932f 100644 --- a/solutions/tests/test_bubble_sort.py +++ b/solutions/tests/test_bubble_sort.py @@ -20,32 +20,60 @@ class TestBubbleSort(unittest.TestCase): """Test the bubble_sort function.""" + # Uncomment for predictive stepping + # actual_1 = bubble_sort([]) + # actual_2 = bubble_sort([1]) + # actual_3 = bubble_sort([2, 1]) + # actual_4 = bubble_sort([3, 2, 1]) + # actual_5 = bubble_sort([2, 3, 100500, 1]) + # actual_6 = bubble_sort(["b", "a", "c"]) + # actual_7 = bubble_sort(["cabbage", "banana", "apple"]) + # actual_8 = bubble_sort([True, False, True, False]) + def test_empty_list(self): """It should return [] for input []""" actual = bubble_sort([]) expected = [] self.assertEqual(actual, expected) - def test_one_element_list(self): + def test_one_int_element_list(self): """It should return [1] for input [1]""" actual = bubble_sort([1]) expected = [1] self.assertEqual(actual, expected) - def test_two_element_list(self): + def test_two_int_element_list(self): """It should return [1, 2] for input [2, 1]""" actual = bubble_sort([2, 1]) expected = [1, 2] self.assertEqual(actual, expected) - def test_three_elements_list(self): + def test_three_int_elements_list(self): """It should return [1, 2, 3] for input [3, 2, 1]""" actual = bubble_sort([3, 2, 1]) expected = [1, 2, 3] self.assertEqual(actual, expected) - def test_four_elements_big_number_list(self): + def test_four_int_elements_big_number_list(self): """It should return [1, 2, 3, 100500] for input [2, 3, 100500, 1]""" actual = bubble_sort([2, 3, 100500, 1]) expected = [1, 2, 3, 100500] self.assertEqual(actual, expected) + + def test_chars_list(self): + """It should return ["a", "b", "c"] for input ["b", "a", "c"]""" + actual = bubble_sort(["b", "a", "c"]) + expected = ["a", "b", "c"] + self.assertEqual(actual, expected) + + def test_string_list(self): + """It should return ["apple", "banana", "cabbage"] for input ["cabbage", "banana", "apple"]""" + actual = bubble_sort(["cabbage", "banana", "apple"]) + expected = ["apple", "banana", "cabbage"] + self.assertEqual(actual, expected) + + def test_bool_list(self): + """It should return [False, False, True, True] for input [True, False, True, False]""" + actual = bubble_sort([True, False, True, False]) + expected = [False, False, True, True] + self.assertEqual(actual, expected) From b192dff601fab1bea81d1754ff48cd17cbf32c23 Mon Sep 17 00:00:00 2001 From: oleksandr-maksymikhin Date: Fri, 3 Jan 2025 10:43:12 +0100 Subject: [PATCH 6/9] added protection from side effect, changes in function docstring description --- solutions/bubble_sort.py | 6 +++--- solutions/tests/test_bubble_sort.py | 7 +++++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/solutions/bubble_sort.py b/solutions/bubble_sort.py index 8d7433af8..9c47f6f23 100644 --- a/solutions/bubble_sort.py +++ b/solutions/bubble_sort.py @@ -18,9 +18,9 @@ def bubble_sort(input_collection: list[any]) -> list[any]: Sort elements in collection by swapping and moving larger elements to the end of collection. Parameters: - input_collection: list[int], collection of unsorted data type int. + input_collection: list[any], collection of unsorted data of any type. - Returns -> list[int], collection of sorted data type int. + Returns -> list[any], collection of sorted elements with any data type. Raises: AssertionError: if collection contains elements of different type. @@ -33,7 +33,7 @@ def bubble_sort(input_collection: list[any]) -> list[any]: >>> bubble_sort([3, 2, 1000000, 1]]) [1, 2, 3, 1000000] """ - collection = input_collection + collection = input_collection.copy() # define collection length collection_length = len(collection) # first loop to traverse the collection diff --git a/solutions/tests/test_bubble_sort.py b/solutions/tests/test_bubble_sort.py index 2143f932f..16bc48460 100644 --- a/solutions/tests/test_bubble_sort.py +++ b/solutions/tests/test_bubble_sort.py @@ -77,3 +77,10 @@ def test_bool_list(self): actual = bubble_sort([True, False, True, False]) expected = [False, False, True, True] self.assertEqual(actual, expected) + + def test_side_effect_protection(self): + """It should return [3, 2, 1] of initial input""" + input_list = [3, 2, 1] + copy_for_sorting = input_list.copy() + bubble_sort(copy_for_sorting) + self.assertEqual(input_list, [3, 2, 1]) From 5818073f0c232be3041d4dac67a4899f00e96e26 Mon Sep 17 00:00:00 2001 From: oleksandr-maksymikhin Date: Fri, 3 Jan 2025 11:14:47 +0100 Subject: [PATCH 7/9] Added defensive assertions (input is not list, input is non-homogeneous collection). Small corrections by commets and variable names --- solutions/bubble_sort.py | 23 +++++++++--- solutions/tests/test_bubble_sort.py | 58 ++++++++++++++++++----------- 2 files changed, 54 insertions(+), 27 deletions(-) diff --git a/solutions/bubble_sort.py b/solutions/bubble_sort.py index 9c47f6f23..d81fcea46 100644 --- a/solutions/bubble_sort.py +++ b/solutions/bubble_sort.py @@ -18,21 +18,32 @@ def bubble_sort(input_collection: list[any]) -> list[any]: Sort elements in collection by swapping and moving larger elements to the end of collection. Parameters: - input_collection: list[any], collection of unsorted data of any type. + input_collection: list[any], collection of unsorted data of any homogeneous type. Returns -> list[any], collection of sorted elements with any data type. Raises: - AssertionError: if collection contains elements of different type. + AssertionError: if input is not a collection. + AssertionError: if collection contains elements of different data types (non-homogeneous). Examples: >>> bubble_sort(1) [1] >>> bubble_sort([1, 3, 2]]) [1, 2, 3] - >>> bubble_sort([3, 2, 1000000, 1]]) - [1, 2, 3, 1000000] + >>> bubble_sort([3, 2, 100500, 1]]) + [1, 2, 3, 100500] """ + + # defensive assertion to check that input is a collection list + assert isinstance(input_collection, list), "Input is not a collection" + + # defensive assertion to check that collection is homogeneous + assert all( + isinstance(item, type(input_collection[0])) for item in input_collection + ), "Collection is not homogeneous" + + # copy collection to avoid side effect collection = input_collection.copy() # define collection length collection_length = len(collection) @@ -40,9 +51,9 @@ def bubble_sort(input_collection: list[any]) -> list[any]: for current_item_index in range(collection_length): # flag to break if the last run didn't swap any item already_sorted = True - # second loop to compare item with adjacent one + # second loop to compare/swap item with adjacent one for swap_index in range(collection_length - current_item_index - 1): - # swap items if next adjacent item is bigger + # swap items if the next adjacent item is smaller if collection[swap_index] > collection[swap_index + 1]: (collection[swap_index], collection[swap_index + 1]) = ( collection[swap_index + 1], diff --git a/solutions/tests/test_bubble_sort.py b/solutions/tests/test_bubble_sort.py index 16bc48460..bb5112650 100644 --- a/solutions/tests/test_bubble_sort.py +++ b/solutions/tests/test_bubble_sort.py @@ -1,12 +1,16 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- """ -Test module for bubble_sort function. +Test module for bubble_sort() function. Test categories: - - Standard cases: typical lists with different lengths + - Standard cases: lists of type int with different lengths - Edge cases: empty lists, single element - - Defensive tests: wrong input types, different input types + - Different data type: char, string, bool + - Defensive tests: + - side effects protection + - input is not a collection + - different data types in the input collection (non-homogeneous) Created on 2024-01-03 Author: Oleksandr Maksymikhin @@ -21,66 +25,78 @@ class TestBubbleSort(unittest.TestCase): """Test the bubble_sort function.""" # Uncomment for predictive stepping - # actual_1 = bubble_sort([]) - # actual_2 = bubble_sort([1]) - # actual_3 = bubble_sort([2, 1]) - # actual_4 = bubble_sort([3, 2, 1]) - # actual_5 = bubble_sort([2, 3, 100500, 1]) - # actual_6 = bubble_sort(["b", "a", "c"]) - # actual_7 = bubble_sort(["cabbage", "banana", "apple"]) - # actual_8 = bubble_sort([True, False, True, False]) - - def test_empty_list(self): + # test_1 = bubble_sort([]) + # test_2 = bubble_sort([1]) + # test_3 = bubble_sort([2, 1]) + # test_4 = bubble_sort([3, 2, 1]) + # test_5 = bubble_sort([2, 3, 100500, 1]) + # test_6 = bubble_sort(["b", "a", "c"]) + # test_7 = bubble_sort(["cabbage", "banana", "apple"]) + # test_8 = bubble_sort([True, False, True, False]) + # test_10 = bubble_sort("apple") + # test_11 = bubble_sort([3, "two", 1]) + + def test_1_empty_list(self): """It should return [] for input []""" actual = bubble_sort([]) expected = [] self.assertEqual(actual, expected) - def test_one_int_element_list(self): + def test_2_one_int_element_list(self): """It should return [1] for input [1]""" actual = bubble_sort([1]) expected = [1] self.assertEqual(actual, expected) - def test_two_int_element_list(self): + def test_3_two_int_elements_list(self): """It should return [1, 2] for input [2, 1]""" actual = bubble_sort([2, 1]) expected = [1, 2] self.assertEqual(actual, expected) - def test_three_int_elements_list(self): + def test_4_three_int_elements_list(self): """It should return [1, 2, 3] for input [3, 2, 1]""" actual = bubble_sort([3, 2, 1]) expected = [1, 2, 3] self.assertEqual(actual, expected) - def test_four_int_elements_big_number_list(self): + def test_5_four_int_elements_list_big_number(self): """It should return [1, 2, 3, 100500] for input [2, 3, 100500, 1]""" actual = bubble_sort([2, 3, 100500, 1]) expected = [1, 2, 3, 100500] self.assertEqual(actual, expected) - def test_chars_list(self): + def test_6_char_elements_list(self): """It should return ["a", "b", "c"] for input ["b", "a", "c"]""" actual = bubble_sort(["b", "a", "c"]) expected = ["a", "b", "c"] self.assertEqual(actual, expected) - def test_string_list(self): + def test_7_string_elements_list(self): """It should return ["apple", "banana", "cabbage"] for input ["cabbage", "banana", "apple"]""" actual = bubble_sort(["cabbage", "banana", "apple"]) expected = ["apple", "banana", "cabbage"] self.assertEqual(actual, expected) - def test_bool_list(self): + def test_8_bool_elements_list(self): """It should return [False, False, True, True] for input [True, False, True, False]""" actual = bubble_sort([True, False, True, False]) expected = [False, False, True, True] self.assertEqual(actual, expected) - def test_side_effect_protection(self): + def test_9_side_effect_protection(self): """It should return [3, 2, 1] of initial input""" input_list = [3, 2, 1] copy_for_sorting = input_list.copy() bubble_sort(copy_for_sorting) self.assertEqual(input_list, [3, 2, 1]) + + def test_10_non_collection_input(self): + """It should raise an assertion error if the input is not a collection""" + with self.assertRaises(AssertionError): + bubble_sort("apple") + + def test_11_non_homogeneous_collection_input(self): + """It should raise an assertion error if the collection is non-homogeneous""" + with self.assertRaises(AssertionError): + bubble_sort([3, "two", 1]) From fb2f5f6fcf0bebdb1bb762cc35c33572274141ac Mon Sep 17 00:00:00 2001 From: oleksandr-maksymikhin Date: Fri, 3 Jan 2025 11:33:58 +0100 Subject: [PATCH 8/9] ready for review, removed unnecessary comments --- solutions/bubble_sort.py | 8 ++++---- solutions/tests/test_bubble_sort.py | 17 ++--------------- 2 files changed, 6 insertions(+), 19 deletions(-) diff --git a/solutions/bubble_sort.py b/solutions/bubble_sort.py index d81fcea46..3cfca7e68 100644 --- a/solutions/bubble_sort.py +++ b/solutions/bubble_sort.py @@ -27,11 +27,11 @@ def bubble_sort(input_collection: list[any]) -> list[any]: AssertionError: if collection contains elements of different data types (non-homogeneous). Examples: - >>> bubble_sort(1) + >>> bubble_sort([1]) [1] - >>> bubble_sort([1, 3, 2]]) + >>> bubble_sort([1, 3, 2]) [1, 2, 3] - >>> bubble_sort([3, 2, 100500, 1]]) + >>> bubble_sort([3, 2, 100500, 1]) [1, 2, 3, 100500] """ @@ -41,7 +41,7 @@ def bubble_sort(input_collection: list[any]) -> list[any]: # defensive assertion to check that collection is homogeneous assert all( isinstance(item, type(input_collection[0])) for item in input_collection - ), "Collection is not homogeneous" + ), "Input collection is not homogeneous" # copy collection to avoid side effect collection = input_collection.copy() diff --git a/solutions/tests/test_bubble_sort.py b/solutions/tests/test_bubble_sort.py index bb5112650..ec5e331cb 100644 --- a/solutions/tests/test_bubble_sort.py +++ b/solutions/tests/test_bubble_sort.py @@ -6,7 +6,7 @@ Test categories: - Standard cases: lists of type int with different lengths - Edge cases: empty lists, single element - - Different data type: char, string, bool + - Different data types: char, string, bool - Defensive tests: - side effects protection - input is not a collection @@ -24,18 +24,6 @@ class TestBubbleSort(unittest.TestCase): """Test the bubble_sort function.""" - # Uncomment for predictive stepping - # test_1 = bubble_sort([]) - # test_2 = bubble_sort([1]) - # test_3 = bubble_sort([2, 1]) - # test_4 = bubble_sort([3, 2, 1]) - # test_5 = bubble_sort([2, 3, 100500, 1]) - # test_6 = bubble_sort(["b", "a", "c"]) - # test_7 = bubble_sort(["cabbage", "banana", "apple"]) - # test_8 = bubble_sort([True, False, True, False]) - # test_10 = bubble_sort("apple") - # test_11 = bubble_sort([3, "two", 1]) - def test_1_empty_list(self): """It should return [] for input []""" actual = bubble_sort([]) @@ -87,8 +75,7 @@ def test_8_bool_elements_list(self): def test_9_side_effect_protection(self): """It should return [3, 2, 1] of initial input""" input_list = [3, 2, 1] - copy_for_sorting = input_list.copy() - bubble_sort(copy_for_sorting) + bubble_sort(input_list) self.assertEqual(input_list, [3, 2, 1]) def test_10_non_collection_input(self): From 8d27f24a51073d4ca2e0971b5f1802bd9ffadeb4 Mon Sep 17 00:00:00 2001 From: oleksandr-maksymikhin Date: Wed, 8 Jan 2025 08:17:12 +0100 Subject: [PATCH 9/9] Added input types verification/ Processed types (int, float, str, bool) Added input types verification/ Processed types (int, float, str, bool) --- solutions/bubble_sort.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/solutions/bubble_sort.py b/solutions/bubble_sort.py index 3cfca7e68..acee5cb30 100644 --- a/solutions/bubble_sort.py +++ b/solutions/bubble_sort.py @@ -2,6 +2,7 @@ # -*- coding: utf-8 -*- """ A module for sorting collection using bubble sort algorithm. +Processed types: int, float, str, bool Module contents: - bubble_sort: sort the collection in ascending order. @@ -10,17 +11,21 @@ Author: Oleksandr Maksymikhin """ +from typing import TypeVar + +T = TypeVar("T", int, float, str, bool) + # def bubble_sort(input_collection: list[int]) -> list[int]: -def bubble_sort(input_collection: list[any]) -> list[any]: +def bubble_sort(input_collection: list[T]) -> list[T]: """Sort collection using bubble sort algorithm. Sort elements in collection by swapping and moving larger elements to the end of collection. Parameters: - input_collection: list[any], collection of unsorted data of any homogeneous type. + input_collection: list[T], collection of unsorted data with data types (T): int, float, str, bool. - Returns -> list[any], collection of sorted elements with any data type. + Returns -> list[T], collection of sorted elements with data types (T): int, float, str, bool. Raises: AssertionError: if input is not a collection.