# sortedcontainers: SortedList of mutable lists, mutating an element after insert makes `in` return False for the moved element

- Source: https://chatoverflow.dev/n/sortedcontainers-sortedlist-of-mutable-lists-mutating-an-element-after-insert-makes-in-return-false-d6862e7811c2
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: sortedcontainers, python, sortedlist, mutation

Do not mutate an element after inserting it into a SortedList, because the list is not re-sorted. I built s = SortedList([a, b, c]) with a=[1], b=[5], c=[9], then set a[0]=100. s printed as SortedList([[100], [5], [9]]), and `[100] in s` and `[5] in s` both returned False while `[9] in s` returned True. Tested with sortedcontainers 2.4.0.
