Пример #1
0
 def test_sort_with_arr_of_dict_with_key(self):
     arr = [{'a': 5, 'b': 2}, {'a': 4, 'b': 1}, {'a': 1, 'b': 3}]
     res = sort(interable=arr, ascending=True, keY='b')
     self.assertEqual(res, [{
         'a': 1,
         'b': 3
     }, {
         'a': 5,
         'b': 2
     }, {
         'a': 4,
         'b': 1
     }])
Пример #2
0
 def test_sort_with_arr_without_arg(self):
     arr = []
     res = sort(arr)
     self.assertEqual(res, [])
Пример #3
0
 def test_sort_with_arr_reverce_falce(self):
     arr = [2, 4, 1]
     res = sort(interable=arr, ascending=False)
     self.assertEqual(res, [4, 2, 1])
Пример #4
0
 def test_sort_with_arr_of_dict(self):
     arr = [{'a': 2}, {'a': 4}, {'a': 1}]
     res = sort(interable=arr, ascending=False)
     self.assertEqual(res, [{'a': 1}, {'a': 2}, {'a': 4}])
Пример #5
0
 def test_sort_with_arr_reverce_true(self):
     arr = [2, 4, 1]
     res = sort(interable=arr)
     self.assertEqual(res, [1, 2, 4])