NB: Assuming objects is a list `objects.sort(lambda left, right: cmp(left.id, right.id))` would suffice.