import bisect from collections import namedtuple bisect.bisect_left() l = [1, 3, 2] l.sort() namedtuple