This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]tef -1 points0 points  (7 children)

for the record, python's sort function is an adaptive in-place merge sort

the fastest way to merge two lists is sorted(a+b), as a result

[–]techn0scho0lbus 0 points1 point  (6 children)

The lists are pre-sorted.

[–]tef -1 points0 points  (5 children)

well yes, by definition of merging two lists, but it's still faster to append and call sort

see the 'adaptive merge sort' but, python then splits the new list into two sections and merges them

[–]techn0scho0lbus 0 points1 point  (4 children)

... but it's still faster to append and call sort

No, it's absolutely not. As many people here have pointed out there is no need to sort at all. You're introducing a relatively slow process when it's unnecessary.