Skip to content

Commit c9feb62

Browse files
authored
Merge branch 'master' into add-typeshed-types
2 parents 0aee809 + f9c4f30 commit c9feb62

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

boltons/listutils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ def sort(self) -> None:
316316
li.sort()
317317
tmp_sorted = sorted(chain.from_iterable(self.lists))
318318
del self.lists[:]
319-
self.lists[0] = tmp_sorted
319+
self.lists.append(tmp_sorted)
320320
self._balance_list(0)
321321

322322
def reverse(self) -> None:

tests/test_listutils.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,14 @@ def test_barrel_list():
5151
bl3[:20:2] = range(0, -10, -1)
5252
assert bl3[6] == -3 # some truly tricky stepping/slicing works
5353

54+
def test_sort_barrel_list():
55+
bl = BarrelList(reversed(range(100000)))
56+
bl.pop(50000)
57+
assert len(bl.lists) > 1
58+
bl.sort()
59+
assert bl[0] == 0
60+
assert bl[-1] == 99999
61+
5462
# roughly increasing random integers
5563
# [ord(i) * x for i, x in zip(os.urandom(1024), range(1024))]
5664
TEST_INTS = [0, 74, 96, 183, 456, 150, 1098, 665, 1752, 1053, 190,

0 commit comments

Comments
 (0)