def __lt__(self, other): try: import re self_text = str(re.sub("[^0-9]", "", self.text())) other_text = str(re.sub("[^0-9]", "", other.text())) return float(self_text) < float(other_text) except Exception: return QListWidgetItem.__lt__(self, other)
def __lt__(self, other): try: return int(self.text()) < int(other.text()) except Exception: return QListWidgetItem.__lt__(self, other)