how to sort list of FileInfo in IronPython
问题 Given a list of FileInfo objects, how do I sort them by date? Specifically I want to sort them by CreationTime in descending order. 回答1: The Pythonic way of doing this would be: fileInfos = list(DirectoryInfo(path).GetFiles()) fileInfos.sort(key=lambda f: f.CreationTime, reverse=True) The list sort method takes a key function that is used to get the sort key for each item. 回答2: DirectoryInfo.GetFiles() returns an array of FileInfo objects. I created a generic list to hold the FileInfo objs,