def list_dir_file_info_sorted(dirpath): result = [] for filename in os.listdir(dirpath): try: result.append(get_file_info(dirpath, filename)) except OSError: pass result.sort(key=lambda info: natural_order_key(info.filename)) return result
def __gt__(self, other): if not isinstance(other, FSNode): raise TypeError() if self.type != other.type: return self.type == 'f' and other.type == 'd' return natural_order_key(self.label) > natural_order_key(other.label)
def SortLinesNaturalOrder(self): self.SelectLines() lines = self.GetSelectedText().split("\n") lines.sort(key=lambda x: natural_order_key(x.strip())) self.ReplaceSelectionAndSelect("\n".join(lines))