def sort_stats(stats): # Sort Docker stats using the same function than processes sortedby = 'cpu_percent' sortedby_secondary = 'memory_usage' if glances_processes.sort_key.startswith('memory'): sortedby = 'memory_usage' sortedby_secondary = 'cpu_percent' sort_stats_processes(stats['containers'], sortedby=sortedby, sortedby_secondary=sortedby_secondary) return stats