python list分组与排序

        # 分组
        records_groups = groupby(records, key=lambda x: x.section)
        for key, record_group in records_groups:
            items = list(record_group)
            # 排序
            items.sort(key=lambda x: x.active_time, reverse=False)

你可能感兴趣的:(python,python)