File tree Expand file tree Collapse file tree 1 file changed +17
-6
lines changed Expand file tree Collapse file tree 1 file changed +17
-6
lines changed Original file line number Diff line number Diff line change @@ -106,12 +106,23 @@ def _generate_staleness_report_per_image(
106
106
}
107
107
)
108
108
109
- staleness_report_rows .sort (
110
- key = lambda x : (
111
- not x ["package" ].startswith ("${\\ color" ), # Stale packages at top of list
112
- - x ["downloads" ], # Sorted by downloads
113
- )
114
- )
109
+ def sort_key (x ):
110
+ # First key: False for stale packages (they start with "${\\color")
111
+ is_current = not x ["package" ].startswith ("${\\ color" )
112
+
113
+ # Second key: downloads count, with "N/A" treated as lowest priority
114
+ downloads = x ["downloads" ]
115
+ if downloads == "N/A" :
116
+ download_value = float ('-inf' ) # Put N/A at the bottom
117
+ else :
118
+ try :
119
+ download_value = float (downloads )
120
+ except (ValueError , TypeError ):
121
+ download_value = float ('-inf' ) # Handle any other non-numeric values
122
+
123
+ return (is_current , download_value )
124
+
125
+ staleness_report_rows .sort (key = sort_key , reverse = True )
115
126
print (
116
127
create_markdown_table (
117
128
[
You can’t perform that action at this time.
0 commit comments