def apply(self, items, inplace=False, item_getter=lambda item: item):
"""Sort sequence `items`
item_getter: Callable that gets an item of `items` and returns an
object that can be sorted with any of the sorters
specified in the SORTSPECS variable. (This allows for
sorting of widgets as long as they can provide a sortable
object.)
inplace: Modify `items` if True, otherwise return a new list
"""
import time
start_time = time.monotonic()
for sorter in self._sortfuncs:
items = sorter(items, inplace=inplace, item_getter=item_getter)
log.debug('-> Sorted %d items by %s in %.3fms',
len(items), self, (time.monotonic()-start_time)*1e3)
if not inplace:
return items
评论列表
文章目录